798
|
1 " Vim syntax file
|
|
2 " Language: Django template
|
|
3 " Maintainer: Dave Hodder <dmh@dmh.org.uk>
|
|
4 " Last Change: 2006 Mar 23
|
|
5
|
|
6 " For version 5.x: Clear all syntax items
|
|
7 " For version 6.x: Quit when a syntax file was already loaded
|
|
8 if version < 600
|
|
9 syntax clear
|
|
10 elseif exists("b:current_syntax")
|
|
11 finish
|
|
12 endif
|
|
13
|
|
14 syntax case match
|
|
15
|
|
16 " Django template built-in tags and parameters
|
|
17 " 'comment' doesn't appear here because it gets special treatment
|
|
18 syn keyword djangoStatement contained as block endblock by cycle debug else
|
|
19 syn keyword djangoStatement contained extends filter endfilter firstof for
|
|
20 syn keyword djangoStatement contained endfor if endif ifchanged endifchanged
|
|
21 syn keyword djangoStatement contained ifequal endifequal ifnotequal
|
|
22 syn keyword djangoStatement contained endifnotequal in include load not now or
|
|
23 syn keyword djangoStatement contained parsed regroup reversed spaceless
|
|
24 syn keyword djangoStatement contained endspaceless ssi templatetag openblock
|
|
25 syn keyword djangoStatement contained closeblock openvariable closevariable
|
|
26 syn keyword djangoStatement contained widthratio with
|
|
27
|
|
28 " Django templete built-in filters
|
|
29 syn keyword djangoFilter contained add addslashes capfirst center cut date
|
|
30 syn keyword djangoFilter contained default default_if_none dictsort
|
|
31 syn keyword djangoFilter contained dictsortreversed divisibleby escape
|
|
32 syn keyword djangoFilter contained filesizeformat first fix_ampersands
|
|
33 syn keyword djangoFilter contained floatformat get_digit join length length_is
|
|
34 syn keyword djangoFilter contained linebreaks linebreaksbr linenumbers ljust
|
|
35 syn keyword djangoFilter contained lower make_list phone2numeric pluralize
|
|
36 syn keyword djangoFilter contained pprint random removetags rjust slice slugify
|
|
37 syn keyword djangoFilter contained stringformat striptags time timesince title
|
|
38 syn keyword djangoFilter contained truncatewords unordered_list upper urlencode
|
|
39 syn keyword djangoFilter contained urlize urlizetrunc wordcount wordwrap yesno
|
|
40
|
|
41 " Django template constants (always surrounded by double quotes)
|
|
42 syn region djangoArgument contained start=/"/ skip=/\\"/ end=/"/
|
|
43
|
|
44 " Django template tag and variable blocks
|
|
45 syn region djangoTagBlock start="{%" end="%}" contains=djangoStatement,djangoFilter,djangoArgument display
|
|
46 syn region djangoVarBlock start="{{" end="}}" contains=djangoFilter,djangoArgument display
|
|
47
|
|
48 " Django template 'comment' tag
|
|
49 syn region djangoComment start="{%\s*comment\s*%}" end="{%\s*endcomment\s*%}"
|
|
50
|
|
51 " Define the default highlighting.
|
|
52 " For version 5.7 and earlier: only when not done already
|
|
53 " For version 5.8 and later: only when an item doesn't have highlighting yet
|
|
54 if version >= 508 || !exists("did_django_syn_inits")
|
|
55 if version < 508
|
|
56 let did_django_syn_inits = 1
|
|
57 command -nargs=+ HiLink hi link <args>
|
|
58 else
|
|
59 command -nargs=+ HiLink hi def link <args>
|
|
60 endif
|
|
61
|
|
62 HiLink djangoTagBlock PreProc
|
|
63 HiLink djangoVarBlock PreProc
|
|
64 HiLink djangoStatement Statement
|
|
65 HiLink djangoFilter Identifier
|
|
66 HiLink djangoArgument Constant
|
|
67 HiLink djangoComment Comment
|
|
68
|
|
69 delcommand HiLink
|
|
70 endif
|
|
71
|
|
72 let b:current_syntax = "django"
|