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