UNPKG

2.81 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: { name:
16 'truncatewords removetags linebreaksbr yesno get_digit timesince random striptags '
17 + 'filesizeformat escape linebreaks length_is ljust rjust cut urlize fix_ampersands '
18 + 'title floatformat capfirst pprint divisibleby add make_list unordered_list urlencode '
19 + 'timeuntil urlizetrunc wordcount stringformat linenumbers slice date dictsort '
20 + 'dictsortreversed default_if_none pluralize lower join center default '
21 + 'truncatewords_html upper length phone2numeric wordwrap time addslashes slugify first '
22 + 'escapejs force_escape iriencode last safe safeseq truncatechars localize unlocalize '
23 + 'localtime utc timezone' },
24 contains: [
25 hljs.QUOTE_STRING_MODE,
26 hljs.APOS_STRING_MODE
27 ]
28 };
29
30 return {
31 name: 'Django',
32 aliases: [ 'jinja' ],
33 case_insensitive: true,
34 subLanguage: 'xml',
35 contains: [
36 hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
37 hljs.COMMENT(/\{#/, /#\}/),
38 {
39 className: 'template-tag',
40 begin: /\{%/,
41 end: /%\}/,
42 contains: [
43 {
44 className: 'name',
45 begin: /\w+/,
46 keywords: { name:
47 'comment endcomment load templatetag ifchanged endifchanged if endif firstof for '
48 + 'endfor ifnotequal endifnotequal widthratio extends include spaceless '
49 + 'endspaceless regroup ifequal endifequal ssi now with cycle url filter '
50 + 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif '
51 + 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix '
52 + 'plural get_current_language language get_available_languages '
53 + 'get_current_language_bidi get_language_info get_language_info_list localize '
54 + 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone '
55 + 'verbatim' },
56 starts: {
57 endsWithParent: true,
58 keywords: 'in by as',
59 contains: [ FILTER ],
60 relevance: 0
61 }
62 }
63 ]
64 },
65 {
66 className: 'template-variable',
67 begin: /\{\{/,
68 end: /\}\}/,
69 contains: [ FILTER ]
70 }
71 ]
72 };
73}
74
75module.exports = django;