django.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. define("dojox/highlight/languages/django", ["dojox/main", "../_base", "./xml", "./html"], function(dojox){
  2. var dh = dojox.highlight, dhc = dh.constants, dhl = dh.languages, x = dhl.xml, h = dhl.html;
  3. dhl.django = {
  4. defaultMode: {
  5. contains: ['tag', 'comment', 'doctype', 'template_comment', 'template_tag', 'variable']
  6. },
  7. case_insensitive: true,
  8. modes: [
  9. x.XML_COMMENT,
  10. h.HTML_DOCTYPE,
  11. {
  12. className: 'tag',
  13. lexems: [dhc.IDENT_RE],
  14. keywords: h.HTML_TAGS,
  15. begin: '<[A-Za-z/]', end: '>',
  16. contains: ['attribute', 'template_comment', 'template_tag', 'variable']
  17. },
  18. x.XML_ATTR,
  19. h.HTML_ATTR,
  20. {
  21. className: 'value',
  22. begin: '"', end: '"',
  23. contains: ['template_comment', 'template_tag', 'variable']
  24. },
  25. h.HTML_VALUE,
  26. {
  27. className: 'template_comment',
  28. begin: '\\{\\%\\s*comment\\s*\\%\\}',
  29. end: '\\{\\%\\s*endcomment\\s*\\%\\}'
  30. },
  31. {
  32. className: 'template_comment',
  33. begin: '\\{#', end: '#\\}'
  34. },
  35. {
  36. className: 'template_tag',
  37. begin: '\\{\\%', end: '\\%\\}',
  38. lexems: [dhc.IDENT_RE],
  39. keywords: {
  40. 'comment': 1, 'endcomment': 1, 'load': 1,
  41. 'templatetag': 1, 'ifchanged': 1, 'endifchanged': 1,
  42. 'if': 1, 'endif': 1, 'firstof': 1, 'for': 1,
  43. 'endfor': 1, 'in': 1, 'ifnotequal': 1,
  44. 'endifnotequal': 1, 'widthratio': 1, 'extends': 1,
  45. 'include': 1, 'spaceless': 1, 'endspaceless': 1,
  46. 'regroup': 1, 'by': 1, 'as': 1, 'ifequal': 1,
  47. 'endifequal': 1, 'ssi': 1, 'now': 1, 'with': 1,
  48. 'cycle': 1, 'url': 1, 'filter': 1, 'endfilter': 1,
  49. 'debug': 1, 'block': 1, 'endblock': 1, 'else': 1
  50. },
  51. contains: ['filter']
  52. },
  53. {
  54. className: 'variable',
  55. begin: '\\{\\{', end: '\\}\\}',
  56. contains: ['filter']
  57. },
  58. {
  59. className: 'filter',
  60. begin: '\\|[A-Za-z]+\\:?', end: '^', excludeEnd: true,
  61. lexems: [dhc.IDENT_RE],
  62. keywords: {
  63. 'truncatewords': 1, 'removetags': 1, 'linebreaksbr': 1,
  64. 'yesno': 1, 'get_digit': 1, 'timesince': 1, 'random': 1,
  65. 'striptags': 1, 'filesizeformat': 1, 'escape': 1,
  66. 'linebreaks': 1, 'length_is': 1, 'ljust': 1, 'rjust': 1,
  67. 'cut': 1, 'urlize': 1, 'fix_ampersands': 1, 'title': 1,
  68. 'floatformat': 1, 'capfirst': 1, 'pprint': 1,
  69. 'divisibleby': 1, 'add': 1, 'make_list': 1,
  70. 'unordered_list': 1, 'urlencode': 1, 'timeuntil': 1,
  71. 'urlizetrunc': 1, 'wordcount': 1, 'stringformat': 1,
  72. 'linenumbers': 1, 'slice': 1, 'date': 1, 'dictsort': 1,
  73. 'dictsortreversed': 1, 'default_if_none': 1,
  74. 'pluralize': 1, 'lower': 1, 'join': 1, 'center': 1,
  75. 'default': 1, 'truncatewords_html': 1, 'upper': 1,
  76. 'length': 1, 'phone2numeric': 1, 'wordwrap': 1, 'time': 1,
  77. 'addslashes': 1, 'slugify': 1, 'first': 1
  78. },
  79. contains: ['argument']
  80. },
  81. {
  82. className: 'argument',
  83. begin: '"', end: '"'
  84. }
  85. ]
  86. };
  87. return dhl.django;
  88. });