Advertisement
Guest User

smarty.lang

a guest
Mar 10th, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 7.97 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!--
  4.     Version:        1.1
  5.     Authors:        Antoni Boucher <bouanto@hotmail.com>
  6.                             Pierre Quillery <pierre@quillery.fr>
  7.  
  8.     Copyright (C) 2010-2011 Antoni Boucher <bouanto@hotmail.com>
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Library General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Library General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Library General Public
  21.     License along with this library; if not, write to the
  22.     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23.     Boston, MA 02111-1307, USA.
  24. -->
  25.  
  26. <language id="stl" _name="Smarty" version="2.0" _section="Scripts">
  27.     <metadata>
  28.     <property name="mimetypes">text/x-smarty,text/plain</property>
  29.     <property name="globs">*.tpl</property>
  30.     <property name="block-comment-start">{*</property>
  31.     <property name="block-comment-end">*}</property>
  32.     </metadata>
  33.  
  34.     <styles>
  35.         <style id="comment" _name="Comment" map-to="def:comment"/>
  36.         <style id="error" _name="Error" map-to="def:error"/>
  37.         <style id="keyword" _name="Keyword" map-to="def:keyword"/>
  38.         <style id="modifier" _name="Modifier" map-to="def:keyword"/>
  39.         <style id="variables" _name="Variables" map-to="def:identifier"/>
  40.         <style id="operator" _name="Operator" map-to="def:operator"/>
  41.         <style id="string" _name="String" map-to="def:string"/>
  42.     </styles>
  43.  
  44.     <definitions>
  45.  
  46.         <!--
  47.             We allow both comment formats :
  48.             - {*} (...) {/*}
  49.             - {* (...) *}
  50.         -->
  51.         <context id="comment-multiline" style-ref="comment" class="comment">
  52.             <start>{\*[}]?</start>
  53.             <end>[{]?[\/]?\*}</end>
  54.             <include>
  55.                 <context ref="def:in-comment"/>
  56.             </include>
  57.         </context>
  58.  
  59.         <!--
  60.             We try to detected improperly closed comment sections.
  61.         -->
  62.         <context id="close-comment-outside-comment" style-ref="error">
  63.             <match>[{]?[\/]?\*}(?!{\*[}]?)</match>
  64.         </context>
  65.  
  66.  
  67.  
  68.  
  69.         <!--
  70.             We accept both variables formats :
  71.             - $classic_php_format
  72.             - #Smarty.configuration.format#
  73.         -->
  74.         <context id="variables" style-ref="variables">
  75.             <match>(\$[a-zA-Z_][a-zA-Z0-9_\.]*|#[a-zA-Z_][a-zA-Z0-9_\.]*#)</match>
  76.         </context>
  77.  
  78.  
  79.  
  80.  
  81.  
  82.         <!--
  83.             There are two strings format : the first one can contain variabless
  84.         -->
  85.         <context id="double-quoted-string" style-ref="string">
  86.             <start>"</start>
  87.             <end>"</end>
  88.             <include>
  89.                 <context ref="variables" />
  90.             </include>
  91.         </context>
  92.  
  93.         <context id="single-quoted-string" style-ref="string">
  94.             <start>'</start>
  95.             <end>'</end>
  96.         </context>
  97.  
  98.  
  99.  
  100.  
  101.  
  102.         <!--
  103.             These are Smarty built-in functions.
  104.         -->
  105.         <context id="built-in-functions" style-ref="keyword">
  106.             <keyword>append</keyword>
  107.             <keyword>assign</keyword>
  108.             <keyword>block</keyword>
  109.             <keyword>call</keyword>
  110.             <keyword>capture</keyword>
  111.             <keyword>config_load</keyword>
  112.             <keyword>debug</keyword>
  113.             <keyword>extends</keyword>
  114.             <keyword>for</keyword>
  115.             <keyword>foreach</keyword>
  116.             <keyword>foreachelse</keyword>
  117.  
  118.             <keyword>@index</keyword>
  119.             <keyword>@iteration</keyword>
  120.             <keyword>@first</keyword>
  121.             <keyword>@last</keyword>
  122.             <keyword>@show</keyword>
  123.             <keyword>@total </keyword>
  124.  
  125.             <keyword>function</keyword>
  126.             <keyword>if</keyword>
  127.             <keyword>elseif</keyword>
  128.             <keyword>else</keyword>
  129.             <keyword>include</keyword>
  130.             <keyword>include_php</keyword>
  131.             <keyword>insert</keyword>
  132.             <keyword>ldelim</keyword>
  133.             <keyword>rdelim</keyword>
  134.             <keyword>literal</keyword>
  135.             <keyword>nocache</keyword>
  136.             <keyword>php</keyword>
  137.             <keyword>section</keyword>
  138.             <keyword>sectionelse</keyword>
  139.  
  140.             <keyword>index</keyword>
  141.             <keyword>index_prev</keyword>
  142.             <keyword>index_next</keyword>
  143.             <keyword>iteration</keyword>
  144.             <keyword>first</keyword>
  145.             <keyword>last</keyword>
  146.             <keyword>rownum</keyword>
  147.             <keyword>loop</keyword>
  148.             <keyword>show</keyword>
  149.             <keyword>total</keyword>
  150.  
  151.             <keyword>strip</keyword>
  152.             <keyword>while</keyword>
  153.         </context>
  154.  
  155.         <!--
  156.             These are Smarty custom functions.
  157.         -->
  158.         <context id="custom-functions" style-ref="keyword">
  159.             <keyword>counter</keyword>
  160.             <keyword>cycle</keyword>
  161.             <keyword>eval</keyword>
  162.             <keyword>fetch</keyword>
  163.             <keyword>html_checkboxes</keyword>
  164.             <keyword>html_image</keyword>
  165.             <keyword>html_options</keyword>
  166.             <keyword>html_radios</keyword>
  167.             <keyword>html_select_date</keyword>
  168.             <keyword>html_select_time</keyword>
  169.             <keyword>html_table</keyword>
  170.             <keyword>mailto</keyword>
  171.             <keyword>math</keyword>
  172.             <keyword>textformat</keyword>
  173.         </context>
  174.  
  175.         <!--
  176.             Smarty modifiers.
  177.         -->
  178.         <context id="modifiers" style-ref="modifier">
  179.             <prefix>^|</prefix>
  180.             <keyword>capitalize</keyword>
  181.             <keyword>cat</keyword>
  182.             <keyword>count_characters</keyword>
  183.             <keyword>count_paragraphs</keyword>
  184.             <keyword>count_sentences</keyword>
  185.             <keyword>count_words</keyword>
  186.             <keyword>date_format</keyword>
  187.             <keyword>default</keyword>
  188.             <keyword>escape</keyword>
  189.             <keyword>indent</keyword>
  190.             <keyword>lower</keyword>
  191.             <keyword>nl2br</keyword>
  192.             <keyword>regex_replace</keyword>
  193.             <keyword>replace</keyword>
  194.             <keyword>spacify</keyword>
  195.             <keyword>string_format</keyword>
  196.             <keyword>strip</keyword>
  197.             <keyword>strip_tags</keyword>
  198.             <keyword>truncate</keyword>
  199.             <keyword>upper</keyword>
  200.             <keyword>wordwrap</keyword>
  201.         </context>
  202.  
  203.  
  204.  
  205.  
  206.         <!--
  207.             Specific Smarty operators.
  208.         -->
  209.         <context id="operators" style-ref="operator" extend-parent="false">
  210.             <keyword>eq</keyword>
  211.             <keyword>ne</keyword>
  212.             <keyword>neq</keyword>
  213.             <keyword>gt</keyword>
  214.             <keyword>lt</keyword>
  215.             <keyword>gte</keyword>
  216.             <keyword>ge</keyword>
  217.             <keyword>lte</keyword>
  218.             <keyword>le</keyword>
  219.             <keyword>lte</keyword>
  220.             <keyword>mod</keyword>
  221.         </context>
  222.  
  223.         <!--
  224.             Special operator for Smarty.
  225.         -->
  226.         <context id="advanced-operators" style-ref="operator" extend-parent="false">
  227.             <match>is (not )?(even|odd)( by)?</match>
  228.         </context>
  229.  
  230.  
  231.  
  232.         <!--
  233.             This defines a block of Smarty content.
  234.         -->
  235.         <context id="block">
  236.             <start>{</start>
  237.             <end>}</end>
  238.             <include>
  239.                 <!-- This will highlight the brackets surrounding our block -->
  240.                 <context sub-pattern="0" where="start" style-ref="keyword"/>
  241.                 <context sub-pattern="0" where="end" style-ref="keyword"/>
  242.  
  243.                 <context ref="php:operators" />
  244.                 <context ref="operators" />
  245.                 <context ref="advanced-operators" />
  246.  
  247.                 <context ref="php:decimal-number"/>
  248.                 <context ref="php:float"/>
  249.                 <context ref="php:boolean"/>
  250.                 <context ref="php:null-value"/>
  251.  
  252.                 <context ref="single-quoted-string"/>
  253.                 <context ref="double-quoted-string"/>
  254.  
  255.                 <context ref="built-in-functions"/>
  256.                 <context ref="custom-functions"/>
  257.                 <context ref="modifiers"/>
  258.  
  259.                 <context ref="variables"/>
  260.  
  261.             </include>
  262.         </context>
  263.  
  264.         <!--
  265.             This allows the presence of escaped content : its still HTML inside,
  266.             but no Smarty is allowed.
  267.         -->
  268.         <context id="escaped-content">
  269.             <start>{literal}</start>
  270.             <end>{/literal}</end>
  271.             <include>
  272.                 <context sub-pattern="0" where="start" style-ref="keyword"/>
  273.                 <context sub-pattern="0" where="end" style-ref="keyword"/>
  274.                 <context ref="html:html"/>
  275.             </include>
  276.         </context>
  277.  
  278.         <!--
  279.             This defines a Smarty template.
  280.         -->
  281.         <context id="smarty">
  282.             <include>
  283.                 <context ref="escaped-content"/>
  284.                 <context ref="comment-multiline"/>
  285.                 <context ref="block"/>
  286.             </include>
  287.         </context>
  288.  
  289.         <!--
  290.             We can still do HTML.
  291.         -->
  292.         <replace id="html:embedded-lang-hook" ref="smarty"/>
  293.  
  294.         <context id="stl" class="no-spell-check">
  295.             <include>
  296.                 <context ref="smarty"/>
  297.                 <context ref="html:html"/>
  298.             </include>
  299.         </context>
  300.  
  301.     </definitions>
  302.  
  303. </language>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement