django.js 2.4 KB

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