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