-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlebars.js
57 lines (52 loc) · 1.43 KB
/
handlebars.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module.exports = function(hljs) {
function copy(mode, parent) {
var result = {};
for (var key in mode) {
if (key != 'contains') {
result[key] = mode[key];
}
var contains = [];
for (var i = 0; mode.contains && i < mode.contains.length; i++) {
contains.push(copy(mode.contains[i], mode));
}
contains = HANDLEBARS_CONTAINS.concat(contains);
if (contains.length) {
result.contains = contains;
}
}
return result;
}
var EXPRESSION_KEYWORDS = "each in with if else unless bindattr action collection debugger log outlet template unbound view yield";
var VARIABLE_CONTAINS =
{
className: 'variable', begin: '[a-zA-Z\.]+',
keywords: EXPRESSION_KEYWORDS
};
var HANDLEBARS_CONTAINS = [
{
className: 'expression',
begin: '{{', end: '}}',
contains: [
{
className: 'begin-block', begin: '\#[a-zA-Z\ \.]+',
keywords: EXPRESSION_KEYWORDS
},
{
className: 'string',
begin: '"', end: '"'
},
{
className: 'end-block', begin: '\\\/[a-zA-Z\ \.]+',
keywords: EXPRESSION_KEYWORDS
},
{
className: 'variable', begin: '[a-zA-Z\.]+',
keywords: EXPRESSION_KEYWORDS
}
]
}
];
var result = copy(hljs.LANGUAGES.xml);
result.case_insensitive = true;
return result;
};