add erb mode
This commit is contained in:
parent
d3cc3ab5aa
commit
790bc5e87a
6 changed files with 165 additions and 2 deletions
|
|
@ -85,6 +85,7 @@ var docs = {
|
||||||
"docs/haml.haml": "Haml",
|
"docs/haml.haml": "Haml",
|
||||||
"docs/Haxe.hx": "haXe",
|
"docs/Haxe.hx": "haXe",
|
||||||
"docs/html.html": "HTML",
|
"docs/html.html": "HTML",
|
||||||
|
"docs/html_ruby.erb": "HTML (Ruby)",
|
||||||
"docs/jade.jade": "Jade",
|
"docs/jade.jade": "Jade",
|
||||||
"docs/java.java": "Java",
|
"docs/java.java": "Java",
|
||||||
"docs/jsp.jsp": "JSP",
|
"docs/jsp.jsp": "JSP",
|
||||||
|
|
|
||||||
25
demo/kitchen-sink/docs/html_ruby.erb
Normal file
25
demo/kitchen-sink/docs/html_ruby.erb
Normal 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 %>
|
||||||
|
|
@ -68,6 +68,7 @@ var supportedModes = {
|
||||||
Haskell: ["hs"],
|
Haskell: ["hs"],
|
||||||
haXe: ["hx"],
|
haXe: ["hx"],
|
||||||
HTML: ["htm|html|xhtml"],
|
HTML: ["htm|html|xhtml"],
|
||||||
|
HTML_Ruby: ["erb|rhtml|html.erb"],
|
||||||
Ini: ["Ini|conf"],
|
Ini: ["Ini|conf"],
|
||||||
Jade: ["jade"],
|
Jade: ["jade"],
|
||||||
Java: ["java"],
|
Java: ["java"],
|
||||||
|
|
@ -133,7 +134,8 @@ var nameOverrides = {
|
||||||
CSharp: "C#",
|
CSharp: "C#",
|
||||||
golang: "Go",
|
golang: "Go",
|
||||||
C_Cpp: "C/C++",
|
C_Cpp: "C/C++",
|
||||||
coffee: "CoffeeScript"
|
coffee: "CoffeeScript",
|
||||||
|
HTML_Ruby: "HTML (Ruby)"
|
||||||
};
|
};
|
||||||
var modesByName = {};
|
var modesByName = {};
|
||||||
for (var name in supportedModes) {
|
for (var name in supportedModes) {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ var HtmlHighlightRules = function() {
|
||||||
next : "style"
|
next : "style"
|
||||||
}, {
|
}, {
|
||||||
token : "meta.tag", // opening tag
|
token : "meta.tag", // opening tag
|
||||||
regex : "<\\/?",
|
regex : "<\\/?(?=\\w)",
|
||||||
next : "tag"
|
next : "tag"
|
||||||
}, {
|
}, {
|
||||||
token : "text",
|
token : "text",
|
||||||
|
|
|
||||||
61
lib/ace/mode/html_ruby.js
Normal file
61
lib/ace/mode/html_ruby.js
Normal 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;
|
||||||
|
});
|
||||||
74
lib/ace/mode/html_ruby_highlight_rules.js
Normal file
74
lib/ace/mode/html_ruby_highlight_rules.js
Normal 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;
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue