UNPKG

2.8 kBJavaScriptView Raw
1/*
2Language: Django
3Description: Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
4Requires: xml.js
5Author: Ivan Sagalaev <maniac@softwaremaniacs.org>
6Contributors: Ilya Baryshev <baryshev@gmail.com>
7Website: https://www.djangoproject.com
8Category: template
9*/
10
11/** @type LanguageFn */
12function django(hljs) {
13 const FILTER = {
14 begin: /\|[A-Za-z]+:?/,
15 keywords: {
16 name:
17 'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags ' +
18 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands ' +
19 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode ' +
20 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort ' +
21 'dictsortreversed default_if_none pluralize lower join center default ' +
22 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first ' +
23 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize ' +
24 'localtime utc timezone'
25 },
26 contains: [
27 hljs.QUOTE_STRING_MODE,
28 hljs.APOS_STRING_MODE
29 ]
30 };
31
32 return {
33 name: 'Django',
34 aliases: ['jinja'],
35 case_insensitive: true,
36 subLanguage: 'xml',
37 contains: [
38 hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
39 hljs.COMMENT(/\{#/, /#\}/),
40 {
41 className: 'template-tag',
42 begin: /\{%/,
43 end: /%\}/,
44 contains: [{
45 className: 'name',
46 begin: /\w+/,
47 keywords: {
48 name:
49 'comment endcomment load templatetag ifchanged endifchanged if endif firstof for ' +
50 'endfor ifnotequal endifnotequal widthratio extends include spaceless ' +
51 'endspaceless regroup ifequal endifequal ssi now with cycle url filter ' +
52 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif ' +
53 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix ' +
54 'plural get_current_language language get_available_languages ' +
55 'get_current_language_bidi get_language_info get_language_info_list localize ' +
56 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone ' +
57 'verbatim'
58 },
59 starts: {
60 endsWithParent: true,
61 keywords: 'in by as',
62 contains: [FILTER],
63 relevance: 0
64 }
65 }]
66 },
67 {
68 className: 'template-variable',
69 begin: /\{\{/,
70 end: /\}\}/,
71 contains: [FILTER]
72 }
73 ]
74 };
75}
76
77export { django as default };