django.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. /** @type LanguageFn */
  11. function django(hljs) {
  12. const FILTER = {
  13. begin: /\|[A-Za-z]+:?/,
  14. keywords: { 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. contains: [
  24. hljs.QUOTE_STRING_MODE,
  25. hljs.APOS_STRING_MODE
  26. ]
  27. };
  28. return {
  29. name: 'Django',
  30. aliases: [ 'jinja' ],
  31. case_insensitive: true,
  32. subLanguage: 'xml',
  33. contains: [
  34. hljs.COMMENT(/\{%\s*comment\s*%\}/, /\{%\s*endcomment\s*%\}/),
  35. hljs.COMMENT(/\{#/, /#\}/),
  36. {
  37. className: 'template-tag',
  38. begin: /\{%/,
  39. end: /%\}/,
  40. contains: [
  41. {
  42. className: 'name',
  43. begin: /\w+/,
  44. keywords: { name:
  45. 'comment endcomment load templatetag ifchanged endifchanged if endif firstof for '
  46. + 'endfor ifnotequal endifnotequal widthratio extends include spaceless '
  47. + 'endspaceless regroup ifequal endifequal ssi now with cycle url filter '
  48. + 'endfilter debug block endblock else autoescape endautoescape csrf_token empty elif '
  49. + 'endwith static trans blocktrans endblocktrans get_static_prefix get_media_prefix '
  50. + 'plural get_current_language language get_available_languages '
  51. + 'get_current_language_bidi get_language_info get_language_info_list localize '
  52. + 'endlocalize localtime endlocaltime timezone endtimezone get_current_timezone '
  53. + 'verbatim' },
  54. starts: {
  55. endsWithParent: true,
  56. keywords: 'in by as',
  57. contains: [ FILTER ],
  58. relevance: 0
  59. }
  60. }
  61. ]
  62. },
  63. {
  64. className: 'template-variable',
  65. begin: /\{\{/,
  66. end: /\}\}/,
  67. contains: [ FILTER ]
  68. }
  69. ]
  70. };
  71. }
  72. export { django as default };