django.js 2.5 KB

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