2024-01-16 21:26:16 +08:00
|
|
|
/*
|
|
|
|
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 <maniac@softwaremaniacs.org>
|
|
|
|
Contributors: Ilya Baryshev <baryshev@gmail.com>
|
|
|
|
Website: https://www.djangoproject.com
|
|
|
|
Category: template
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @type LanguageFn */
|
|
|
|
function django(hljs) {
|
|
|
|
const FILTER = {
|
2023-12-18 13:12:25 +08:00
|
|
|
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 {
|
2024-01-16 21:26:16 +08:00
|
|
|
name: 'Django',
|
2023-12-18 13:12:25 +08:00
|
|
|
aliases: ['jinja'],
|
|
|
|
case_insensitive: true,
|
|
|
|
subLanguage: 'xml',
|
|
|
|
contains: [
|
2024-01-16 21:26:16 +08:00
|
|
|
hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
|
|
|
|
hljs.COMMENT(/\{#/, /#\}/),
|
2023-12-18 13:12:25 +08:00
|
|
|
{
|
|
|
|
className: 'template-tag',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /\{%/,
|
|
|
|
end: /%\}/,
|
|
|
|
contains: [{
|
|
|
|
className: 'name',
|
|
|
|
begin: /\w+/,
|
|
|
|
keywords: {
|
|
|
|
name:
|
2023-12-18 13:12:25 +08:00
|
|
|
'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'
|
2024-01-16 21:26:16 +08:00
|
|
|
},
|
|
|
|
starts: {
|
|
|
|
endsWithParent: true,
|
|
|
|
keywords: 'in by as',
|
|
|
|
contains: [FILTER],
|
|
|
|
relevance: 0
|
2023-12-18 13:12:25 +08:00
|
|
|
}
|
2024-01-16 21:26:16 +08:00
|
|
|
}]
|
2023-12-18 13:12:25 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
className: 'template-variable',
|
2024-01-16 21:26:16 +08:00
|
|
|
begin: /\{\{/,
|
|
|
|
end: /\}\}/,
|
2023-12-18 13:12:25 +08:00
|
|
|
contains: [FILTER]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2024-01-16 21:26:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = django;
|