Vous n'êtes pas identifié(e).
Salut à tous !
J'ai créé un fichier qui fait la coloration syntaxique pour les templates de Django.
Le voici :
<?xml version="1.0" encoding="UTF-8"?>
<language id="dtl" _name="Django's template language" version="2.0" _section="Scripts">
<metadata>
<property name="mimetypes">text/html</property>
<property name="globs">*.html;*.htm;*.tpl</property>
</metadata>
<styles>
<style id="commentaire" _name="Commentaire" map-to="def:comment"/>
<style id="chaineG" _name="Chaîne de caractères" map-to="def:string"/>
<style id="chaineA" _name="Chaîne de caractères" map-to="def:string"/>
<style id="included-file" _name="Included File" map-to="def:string"/>
<style id="motCle" _name="Mot-clé" map-to="def:keyword"/>
<style id="filtre" _name="Filtre" map-to="def:keyword"/>
<style id="variable" _name="Variable" map-to="def:identifier"/>
<style id="operateur" _name="Opérateur" map-to="def:operator"/>
<style id="nombre" _name="Nombre" map-to="def:number"/>
</styles>
<definitions>
<context id="comment-multiline" style-ref="commentaire">
<start>{% ?comment ?%}</start>
<end>{% ?endcomment ?%}</end>
<include>
<context ref="def:in-comment"/>
</include>
</context>
<context id="commentaire" end-at-line-end="true" style-ref="commentaire">
<start>{#</start>
<end>#}</end>
</context>
<context id="variable" style-ref="variable">
<match>[a-zA-Z_][a-zA-Z0-9_\.]*</match>
</context>
<context id="chaineG" end-at-line-end="true" style-ref="chaineG">
<start>"</start>
<end>"</end>
</context>
<context id="chaineA" end-at-line-end="true" style-ref="chaineA">
<start>'</start>
<end>'</end>
</context>
<context id="motsCles" style-ref="motCle">
<keyword>autoescape</keyword>
<keyword>endautoescape</keyword>
<keyword>block</keyword>
<keyword>endblock</keyword>
<keyword>csrf_token</keyword>
<keyword>cycle</keyword>
<keyword>debug</keyword>
<keyword>extends</keyword>
<keyword>else</keyword>
<keyword>filter</keyword>
<keyword>endfilter</keyword>
<keyword>firstof</keyword>
<keyword>for</keyword>
<keyword>endfor</keyword>
<keyword>empty</keyword>
<keyword>if</keyword>
<keyword>endif</keyword>
<keyword>not</keyword>
<keyword>in</keyword>
<keyword>ifchanged</keyword>
<keyword>endifchanged</keyword>
<keyword>ifequal</keyword>
<keyword>endifequal</keyword>
<keyword>ifnotequal</keyword>
<keyword>endifnotequal</keyword>
<keyword>include</keyword>
<keyword>load</keyword>
<keyword>now</keyword>
<keyword>regroup</keyword>
<keyword>spaceless</keyword>
<keyword>endspaceless</keyword>
<keyword>ssi</keyword>
<keyword>templatetag</keyword>
<keyword>url</keyword>
<keyword>widthratio</keyword>
<keyword>with</keyword>
<keyword>endwith</keyword>
<keyword>and</keyword>
<keyword>or</keyword>
<keyword>regroup</keyword>
<keyword>as</keyword>
<keyword>lorem</keyword>
<keyword>trans</keyword>
<keyword>blocktrans</keyword>
<keyword>endblocktrans</keyword>
<keyword>plural</keyword>
<keyword>get_current_language</keyword>
<keyword>get_available_languages</keyword>
<keyword>get_current_language_bidi</keyword>
</context>
<context id="filtres" style-ref="filtre">
<prefix>^|</prefix>
<keyword>add</keyword>
<keyword>addslashes</keyword>
<keyword>capfirst</keyword>
<keyword>center</keyword>
<keyword>cut</keyword>
<keyword>date</keyword>
<keyword>default</keyword>
<keyword>default_if_none</keyword>
<keyword>dictsort</keyword>
<keyword>dictsortreversed</keyword>
<keyword>divisibleby</keyword>
<keyword>escape</keyword>
<keyword>escapejs</keyword>
<keyword>filesizeformat</keyword>
<keyword>first</keyword>
<keyword>fix_ampersands</keyword>
<keyword>floatformat</keyword>
<keyword>force_escape</keyword>
<keyword>get_digit</keyword>
<keyword>iriencode</keyword>
<keyword>join</keyword>
<keyword>last</keyword>
<keyword>length</keyword>
<keyword>length_is</keyword>
<keyword>linebreaks</keyword>
<keyword>linebreaksbr</keyword>
<keyword>linenumbers</keyword>
<keyword>ljust</keyword>
<keyword>lower</keyword>
<keyword>make_list</keyword>
<keyword>phone2numeric</keyword>
<keyword>pluralize</keyword>
<keyword>pprint</keyword>
<keyword>random</keyword>
<keyword>removetags</keyword>
<keyword>rjust</keyword>
<keyword>safe</keyword>
<keyword>safeseq</keyword>
<keyword>slice</keyword>
<keyword>slugify</keyword>
<keyword>stringformat</keyword>
<keyword>striptags</keyword>
<keyword>time</keyword>
<keyword>timesince</keyword>
<keyword>timeuntil</keyword>
<keyword>title</keyword>
<keyword>truncatewords</keyword>
<keyword>truncatewords_html</keyword>
<keyword>unordered_list</keyword>
<keyword>upper</keyword>
<keyword>urlencode</keyword>
<keyword>urlize</keyword>
<keyword>urlizetrunc</keyword>
<keyword>wordcount</keyword>
<keyword>wordwrap</keyword>
<keyword>yesno</keyword>
<keyword>apnumber</keyword>
<keyword>intcomma</keyword>
<keyword>intword</keyword>
<keyword>ordinal</keyword>
<keyword>naturalday</keyword>
</context>
<context id="operateur" style-ref="operateur">
<match>(\=\=|\!\=|<\=|>\=|>|<|\=)</match>
</context>
<context id="nombre" style-ref="nombre">
<match>[0-9]*</match>
</context>
<context id="variable-block" end-at-line-end="true">
<start>{{</start>
<end>}}</end>
<include>
<context sub-pattern="0" where="start" style-ref="motCle"/>
<context sub-pattern="0" where="end" style-ref="motCle"/>
<context ref="chaineG"/>
<context ref="chaineA"/>
<context ref="filtres"/>
<context ref="motsCles"/>
<context ref="nombre"/>
<context ref="variable"/>
</include>
</context>
<context id="dtl-block" end-at-line-end="true">
<start>{%</start>
<end>%}</end>
<include>
<context sub-pattern="0" where="start" style-ref="motCle"/>
<context sub-pattern="0" where="end" style-ref="motCle"/>
<context ref="commentaire"/>
<context ref="chaineG"/>
<context ref="chaineA"/>
<context ref="motsCles"/>
<context ref="filtres"/>
<context ref="operateur"/>
<context ref="nombre"/>
<context ref="variable"/>
</include>
</context>
<context id="django">
<include>
<context ref="comment-multiline"/>
<context ref="commentaire"/>
<context ref="dtl-block"/>
<context ref="variable-block"/>
</include>
</context>
<replace id="html:embedded-lang-hook" ref="django"/>
<context id="dtl" class="no-spell-check">
<include>
<context ref="django"/>
<context ref="html:html"/>
</include>
</context>
</definitions>
</language>
Vous devez copier ce fichier dans le dossier gtksourceview-2.0/language-specs de votre système.
Chez moi (Ubuntu 10.04), il se trouve ici :
/usr/share/gtksourceview-2.0/language-specs
Pour sélectionner cette coloration, allez dans le menu Affichage->Mode de coloration->Scripts->Django's template language.
Si vous avez des commentaires sur ce fichier ou si vous trouvez des bugs, dites-le-moi !
En espérant que ça vous soit utile.
Voici des captures d'écran :
avec ce fichier :
sans ce fichier :
(C'est beaucoup plus lisible avec, n'est-ce pas ?)
À plus !
Hors ligne
Merci, ça va m'être bien pratique !
Hors ligne