This extension adds support for the Stencil template language.
This extension includes a TextMate grammar wirtten specifically for Stencil. This should allow for the best possible syntax highlighting:
Also included is a Stencil for HTML language that supports both Stencil and HTML:
Snippets are included for all common tags:
- block: a
blocktag. - extends: an
extendstag. - filter: a
filtertag. - for: a
fortag to iterate over an array. - forempty: a
fortag to iterate over an array that includes anemptytag. - fordict: a
fortag to iterate over a dictionary. - fordictempty: a
fortag to iterate over a dictionary that includes anemptytag. - if: an
iftag. - ifelse: an
iftag that includes anelsetag. - ifif: an
iftag that includes aneliftag. - ififelse: an
iftag that includes both aneliftag and anelsetag. - include: an
includetag.
Snippets include tab stops so you can easily move around:
Autoclosing pairs are set up for {{, {% and {# so you can easily type variables, tags and comments:
You can also use the Toggle Comment keyboard shortcut to create comments.
This will generate a {# #} comment in Stencil templates and a <!-- --> comment in Stencil for HTML templates.
Indentation rules are included for both Stencil and Stencil for HTML. Thanks to these rules, Visual Studio Code will suggest the proper indentation.
This makes moving lines around a lot easier:
Even better, the Reindent Lines command will just work:
This extension is set up to use the following file extensions:
.stencil: Stencil templates..html.stencil: Stencil for HTML templates.
If you use Stencil exclusively for HTML and would like to use the .stencil extension for Stencil for HTML instead, add the following to your Visual Studio Code preferences:
"files.associations": {
"*.stencil": "stencil-html"
}
Mixed grammars are not without issues and neither is Stencil for HTML. Because of the way grammars are embedded, Stencil will not be supported in embedded CSS or JavaScript. The template will work fine, but syntax highlighting and indentation will be off. I am looking into ways to improve this, but a perfect solution may not be possible.





