PageRenderTime 254ms CodeModel.GetById 110ms app.highlight 13ms RepoModel.GetById 118ms app.codeStats 1ms

/dtl.lang

http://gedit-django-template-language.googlecode.com/
Unknown | 339 lines | 308 code | 31 blank | 0 comment | 0 complexity | f6897cd99ecc04c9779966a615df763c MD5 | raw file
  1<?xml version="1.0" encoding="UTF-8"?>
  2<language id="dtl" _name="DTL" version="2.0" _section="Markup">
  3  <metadata>
  4    <property name="mimetypes">text/html;</property>
  5    <property name="globs">*.dtl;*.html;</property>
  6    <property name="line-comment-start">**</property>
  7    <property name="block-comment-start">**</property>
  8    <property name="block-comment-end">**</property>
  9  </metadata>
 10
 11  <styles>
 12    <style id="embedded"         _name="Comment" map-to="def:embedded"/>
 13    <style id="comment"         _name="Comment" map-to="def:comment"/>
 14    <style id="error"           _name="Error" map-to="def:error"/>
 15    <style id="variable"        _name="Variable" map-to="def:identifier"/>
 16    <style id="escape"          _name="Escaped Character" map-to="def:special-char"/>
 17    <style id="string"          _name="String" map-to="def:string"/>
 18    <style id="here-doc"        _name="Heredoc" map-to="def:string"/>
 19    <style id="here-doc-bound"  _name="Heredoc Bound" map-to="def:keyword"/>
 20    <style id="keyword"         _name="Keyword" map-to="def:keyword"/>
 21    <style id="operator"        _name="Operator" map-to="def:operator"/>
 22    <style id="filters"         _name="Null Value" map-to="def:boolean"/>
 23    <style id="boolean"         _name="Boolean value" map-to="def:boolean"/>
 24    <style id="floating-point"  _name="Floating point number" map-to="def:floating-point"/>
 25    <style id="decimal"         _name="Decimal number" map-to="def:decimal"/>
 26    <style id="octal"           _name="Octal number" map-to="def:base-n-integer"/>
 27    <style id="hexadecimal"     _name="Hexadecimal number" map-to="def:base-n-integer"/>
 28  </styles>
 29
 30  <definitions>
 31
 32
 33    <!-- Html comments are more permissive than xml comments -->
 34    <context id="comment" style-ref="comment">
 35        <start>&lt;!--</start>
 36        <end>--\s*&gt;</end>
 37        <include>
 38            <context ref="def:in-comment"/>
 39        </include>
 40    </context>
 41
 42    <context id="bash-line-comment" style-ref="comment" end-at-line-end="true" extend-parent="false">
 43      <start>{#</start>
 44      <end>#}</end>
 45      <include>
 46        <context ref="def:in-line-comment"/>
 47      </include>
 48    </context>
 49
 50    <context id="cpp-line-comment" style-ref="comment" end-at-line-end="true" extend-parent="false">
 51      <start>//</start>
 52      <include>
 53        <context ref="def:in-line-comment"/>
 54      </include>
 55    </context>
 56
 57    <context id="c-block-comment" style-ref="comment">
 58      <start>\*</start>
 59      <end>\*</end>
 60      <include>
 61        <context ref="def:in-line-comment"/>
 62      </include>
 63    </context>
 64
 65    <context id="close-comment-outside-comment" style-ref="error">
 66      <match>\*/(?!\*)</match>
 67    </context>
 68
 69    <context id="escape" style-ref="escape">
 70      <match>\\((\\|"|n|t|\$|r)|[0-7]{1,3}|x[0-9a-fA-F]{1,2})</match>
 71    </context>
 72
 73    <context id="variable" style-ref="variable">
 74      <match>[|]+[a-zA-Z_][a-zA-Z0-9_]*</match>
 75    </context>
 76
 77    <context id="array-operators" style-ref="variable">
 78      <match>(\[|\])</match>
 79    </context>
 80
 81    <context id="string-var">
 82      <include>
 83        <context ref="variable"/>
 84        <context id="curly-var" style-ref="variable" >
 85          <start>{(?=\$)</start>
 86          <end>}</end>
 87          <include>
 88            <context ref="string-var"/>
 89          </include>
 90        </context>
 91        <context id="backwards-curly-var" style-ref="boolean">
 92          <start>\${</start>
 93          <end>}</end>
 94          <include>
 95            <context ref="string-var"/>
 96          </include>
 97        </context>
 98      </include>
 99    </context>
100
101    <context id="double-quoted-string" style-ref="string">
102      <start>"</start>
103      <end>"</end>
104      <include>
105        <context ref="escape"/>
106        <context ref="string-var"/>
107        <context ref="def:line-continue"/>
108      </include>
109    </context>
110
111    <context id="single-quoted-string" style-ref="string">
112      <start>'</start>
113      <end>'</end>
114      <include>
115        <context style-ref="def:special-char">
116          <match>\\['\\]</match>
117        </context>
118        <context ref="def:line-continue"/>
119      </include>
120    </context>
121
122    <context id="backtick-string" style-ref="string" extend-parent="false">
123      <start>`</start>
124      <end>`</end>
125      <include>
126        <context ref="escape"/>
127        <context ref="def:line-continue"/>
128      </include>
129    </context>
130
131    <context id="here-doc-string" style-ref="here-doc" extend-parent="true">
132      <start>(&lt;&lt;&lt;)\s?([a-zA-Z_][a-zA-Z0-9_]*)</start>
133      <end>^(\%{2@start});?$</end>
134      <include>
135        <context sub-pattern="0" where="start" style-ref="here-doc-bound"/>
136        <context sub-pattern="1" where="end" style-ref="here-doc-bound"/>
137        <context ref="escape"/>
138        <context ref="string-var"/>
139        <context ref="def:line-continue"/>
140      </include>
141    </context>
142
143    <context id="keywords" style-ref="keyword">
144        <keyword>autoescape</keyword>
145        <keyword>block</keyword>
146        <keyword>endblock</keyword>
147        <keyword>comment</keyword>
148        <keyword>cycle</keyword>
149        <keyword>debug</keyword>
150        <keyword>extends</keyword>
151        <keyword>filter</keyword>
152        <keyword>firstof</keyword>
153        <keyword>for</keyword>
154        <keyword>endfor</keyword>
155        <keyword>if</keyword>
156        <keyword>endif</keyword>
157        <keyword>ifchanged</keyword>
158        <keyword>endifchanged</keyword>
159        <keyword>ifequal</keyword>
160        <keyword>endifequal</keyword>
161        <keyword>ifnotequal</keyword>
162        <keyword>endifnotequal</keyword>
163        <keyword>include</keyword>
164        <keyword>load</keyword>
165        <keyword>now</keyword>
166        <keyword>regroup</keyword>
167        <keyword>spaceless</keyword>
168        <keyword>ssi</keyword>
169        <keyword>templatetag</keyword>
170        <keyword>url</keyword>
171        <keyword>widthratio</keyword>
172        <keyword>with</keyword>
173        <keyword>endwith</keyword>
174        <keyword>in</keyword>
175        <keyword>else</keyword>
176        <keyword>lorem</keyword>
177        <keyword>trans</keyword>
178    </context>
179
180    <context id="operators" style-ref="operator" extend-parent="false">
181      <match>[-.~^@,;:/%|\=\+\*\!\?&amp;&lt;&gt;()]</match>
182    </context>
183
184
185    <context id="filters" style-ref="filters">
186      <prefix>(?i)\b</prefix> <!-- case insensitive -->
187        <keyword>add</keyword>
188        <keyword>addslashes</keyword>
189        <keyword>capfirst</keyword>
190        <keyword>center</keyword>
191        <keyword>cut</keyword>
192        <keyword>date</keyword>
193        <keyword>default</keyword>
194        <keyword>default_if_none</keyword>
195        <keyword>dictsort</keyword>
196        <keyword>dictsortreversed</keyword>
197        <keyword>divisibleby</keyword>
198        <keyword>escape</keyword>
199        <keyword>escapejs</keyword>
200        <keyword>filesizeformat</keyword>
201        <keyword>first</keyword>
202        <keyword>fix_ampersands</keyword>
203        <keyword>floatformat</keyword>
204        <keyword>force_escape</keyword>
205        <keyword>get_digit</keyword>
206        <keyword>iriencode</keyword>
207        <keyword>join</keyword>
208        <keyword>last</keyword>
209        <keyword>length</keyword>
210        <keyword>length_is</keyword>
211        <keyword>linebreaks</keyword>
212        <keyword>linebreaksbr</keyword>
213        <keyword>linenumbers</keyword>
214        <keyword>ljust</keyword>
215        <keyword>lower</keyword>
216        <keyword>make_list</keyword>
217        <keyword>phone2numeric</keyword>
218        <keyword>pluralize</keyword>
219        <keyword>pprint</keyword>
220        <keyword>random</keyword>
221        <keyword>removetags</keyword>
222        <keyword>rjust</keyword>
223        <keyword>safe</keyword>
224        <keyword>slice</keyword>
225        <keyword>slugify</keyword>
226        <keyword>stringformat</keyword>
227        <keyword>striptags</keyword>
228        <keyword>time</keyword>
229        <keyword>timesince</keyword>
230        <keyword>timeuntil</keyword>
231        <keyword>title</keyword>
232        <keyword>truncatewords</keyword>
233        <keyword>truncatewords_html</keyword>
234        <keyword>unordered_list</keyword>
235        <keyword>upper</keyword>
236        <keyword>urlencode</keyword>
237        <keyword>urlize</keyword>
238        <keyword>urlizetrunc</keyword>
239        <keyword>wordcount</keyword>
240        <keyword>wordwrap</keyword>
241        <keyword>yesno</keyword>
242        <keyword>apnumber</keyword>
243        <keyword>intcomma</keyword>
244        <keyword>intword</keyword>
245        <keyword>ordinal</keyword>
246        <keyword>naturalday</keyword>
247        <keyword>textile</keyword>
248        <keyword>markdown</keyword>
249        <keyword>restructuredtext</keyword>
250
251    </context>
252
253    <context id="boolean" style-ref="boolean">
254      <prefix>(?i)\b</prefix> <!-- case insensitive -->
255      <keyword>false</keyword>
256      <keyword>true</keyword>
257    </context>
258
259    <context id="float" style-ref="floating-point">
260      <match extended="true">
261        (?&lt;![\w\.])
262        ([0-9]+[Ee][+-]?[0-9]+ |
263         ([0-9]*\.[0-9]+ | [0-9]+\.[0-9]*)([Ee][+-]?[0-9]+)?)
264        (?![\w\.])
265      </match>
266    </context>
267
268    <context id="decimal-number" style-ref="decimal">
269      <match extended="true">
270        (?&lt;![\w\.])
271        [+-]?([1-9][0-9]*|0)
272        (?![\w\.])
273      </match>
274    </context>
275
276    <context id="octal-number" style-ref="octal">
277      <match extended="true">
278        (?&lt;![\w\.])
279        [+-]?0[0-7]+
280        (?![\w\.])
281      </match>
282    </context>
283
284    <context id="hexadecimal-number" style-ref="hexadecimal">
285      <match extended="true">
286        (?&lt;![\w\.])
287        [+-]?0x[0-9a-fA-F]+
288        (?![\w\.])
289      </match>
290    </context>
291
292    <context id="dtl-block" style-ref="embedded" end-at-line-end="true">
293      <start>&#123;(&#123;|&#37;)(/?)</start>
294      <end>(&#125;|&#37;)&#125;</end>
295      <include>
296        <context sub-pattern="0" where="start" style-ref="boolean"/>
297        <context sub-pattern="0" where="end" style-ref="boolean"/>
298        <context ref="cpp-line-comment"/>
299        <context ref="bash-line-comment"/>
300        <context ref="c-block-comment"/>
301        <context ref="double-quoted-string"/>
302        <context ref="single-quoted-string"/>
303        <context ref="backtick-string"/>
304        <context ref="here-doc-string"/>
305        <context ref="variable"/>
306        <context ref="array-operators"/>
307        <context ref="keywords"/>
308        <context ref="operators"/>
309        <context ref="filters"/>
310        <context ref="boolean"/>
311        <context ref="float"/>
312        <context ref="decimal-number"/>
313        <context ref="octal-number"/>
314        <context ref="hexadecimal-number"/>
315      </include>
316    </context>
317
318    <context id="dtl-comment-block" style-ref="comment" end-at-line-end="false">
319      <start>&#123;(&#35;)(/?)</start>
320      <end>(&#35;)&#125;</end>
321      <include>
322        <context sub-pattern="0" where="start" style-ref="comment"/>
323        <context sub-pattern="0" where="end" style-ref="comment"/>
324        <context ref="c-block-comment"/>
325      </include>
326    </context>
327
328    <replace id="html:embedded-lang-hook" ref="dtl-block"/>
329
330    <context id="dtl">
331      <include>
332        <context ref="dtl-comment-block"/>
333        <context ref="dtl-block"/>
334        <context ref="html:html"/>
335      </include>
336    </context>
337
338  </definitions>
339</language>