-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
Copy pathdjango.js
73 lines (71 loc) · 2.72 KB
/
django.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Language: Django
Description: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
Requires: xml.js
Author: Ivan Sagalaev <[email protected]>
Contributors: Ilya Baryshev <[email protected]>
Website: https://www.djangoproject.com
Category: template
*/
/** @type LanguageFn */
export default function(hljs) {
const FILTER = {
begin: /\|[A-Za-z]+:?/,
keywords: { name:
'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags '
+ 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands '
+ 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode '
+ 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort '
+ 'dictsortreversed default_if_none pluralize lower join center default '
+ 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first '
+ 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize '
+ 'localtime utc timezone' },
contains: [
hljs.QUOTE_STRING_MODE,
hljs.APOS_STRING_MODE
]
};
return {
name: 'Django',
aliases: [ 'jinja' ],
case_insensitive: true,
subLanguage: 'xml',
contains: [
hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
hljs.COMMENT(/\{#/, /#\}/),
{
className: 'template-tag',
begin: /\{%/,
end: /%\}/,
contains: [
{
className: 'name',
begin: /\w+/,
keywords: { name:
'comment endcomment load templatetag ifchanged endifchanged if endif firstof for '
+ 'endfor ifnotequal endifnotequal widthratio extends include spaceless '
+ 'endspaceless regroup ifequal endifequal ssi now with cycle url filter '
+ 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif '
+ 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix '
+ 'plural get_current_language language get_available_languages '
+ 'get_current_language_bidi get_language_info get_language_info_list localize '
+ 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone '
+ 'verbatim' },
starts: {
endsWithParent: true,
keywords: 'in by as',
contains: [ FILTER ],
relevance: 0
}
}
]
},
{
className: 'template-variable',
begin: /\{\{/,
end: /\}\}/,
contains: [ FILTER ]
}
]
};
}