add erb mode

This commit is contained in:
nightwing 2013-05-08 18:44:37 +04:00
commit 790bc5e87a
6 changed files with 165 additions and 2 deletions

View file

@ -85,6 +85,7 @@ var docs = {
"docs/haml.haml": "Haml",
"docs/Haxe.hx": "haXe",
"docs/html.html": "HTML",
"docs/html_ruby.erb": "HTML (Ruby)",
"docs/jade.jade": "Jade",
"docs/java.java": "Java",
"docs/jsp.jsp": "JSP",

View file

@ -0,0 +1,25 @@
<h1>Listing Books</h1>
<table>
<tr>
<th>Title</th>
<th>Summary</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @books.each do |book| %>
<tr>
<td><%= book.title %></td>
<td><%= book.content %></td>
<td><%= link_to 'Show', book %></td>
<td><%= link_to 'Edit', edit_book_path(book) %></td>
<td><%= link_to 'Remove', book, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New book', new_book_path %>

View file

@ -68,6 +68,7 @@ var supportedModes = {
Haskell: ["hs"],
haXe: ["hx"],
HTML: ["htm|html|xhtml"],
HTML_Ruby: ["erb|rhtml|html.erb"],
Ini: ["Ini|conf"],
Jade: ["jade"],
Java: ["java"],
@ -133,7 +134,8 @@ var nameOverrides = {
CSharp: "C#",
golang: "Go",
C_Cpp: "C/C++",
coffee: "CoffeeScript"
coffee: "CoffeeScript",
HTML_Ruby: "HTML (Ruby)"
};
var modesByName = {};
for (var name in supportedModes) {

View file

@ -86,7 +86,7 @@ var HtmlHighlightRules = function() {
next : "style"
}, {
token : "meta.tag", // opening tag
regex : "<\\/?",
regex : "<\\/?(?=\\w)",
next : "tag"
}, {
token : "text",

61
lib/ace/mode/html_ruby.js Normal file
View file

@ -0,0 +1,61 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var Tokenizer = require("../tokenizer").Tokenizer;
var HtmlRubyHighlightRules = require("./html_ruby_highlight_rules").HtmlRubyHighlightRules;
var HtmlMode = require("./html").Mode;
var JavaScriptMode = require("./javascript").Mode;
var CssMode = require("./css").Mode;
var RubyMode = require("./ruby").Mode;
var Mode = function() {
HtmlMode.call(this);
var highlighter = new HtmlRubyHighlightRules();
this.$tokenizer = new Tokenizer(highlighter.getRules());
this.$embeds = highlighter.getEmbeds();
this.createModeDelegates({
"js-": JavaScriptMode,
"css-": CssMode,
"ruby-": RubyMode
});
};
oop.inherits(Mode, HtmlMode);
(function() {
}).call(Mode.prototype);
exports.Mode = Mode;
});

View file

@ -0,0 +1,74 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
define(function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules;
var HtmlRubyHighlightRules = function() {
HtmlHighlightRules.call(this);
for (var i in this.$rules) {
this.$rules[i].unshift({
regex: "<%%|%%>",
token: "constant.language.escape"
}, {
token : "comment.start.erb",
regex : "<%#",
push : [{regex: "%>", next: "pop"}]
}, {
token : "support.ruby_tag",
regex : "<%+(?!>)[-=]?",
push : "ruby-start"
});
}
this.embedRules(RubyHighlightRules, "ruby-");
this.$rules["ruby-start"].unshift({
token : "support.ruby_tag",
regex : "%>",
next : "pop"
}, {
token: "comment",
regex: /#(?:[^%]|%[^>])*/
});
this.normalizeRules();
};
oop.inherits(HtmlRubyHighlightRules, HtmlHighlightRules);
exports.HtmlRubyHighlightRules = HtmlRubyHighlightRules;
});