django.js 2.7 KB

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