ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Twig

A Sublime Text Package that provides syntax highlighting, completions, snippets & more for PHP Twig templates.

Labels Twig, templates, PHP, syntax

Details

  • 2012.01.20.08.54.14
    1.0.3
  • github.​com
  • github.​com
  • 1 month ago
  • 2 hours ago
  • 9 years ago

Installs

  • Total 96K
  • Win 41K
  • Mac 32K
  • Linux 23K
Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5 Oct 4 Oct 3 Oct 2 Oct 1 Sep 30 Sep 29 Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15
Windows 14 12 9 17 13 6 8 17 14 15 11 17 14 12 14 15 17 16 20 15 7 11 22 17 20 18 11 10 14 21 5 14 16 5 4 11 8 5 5 12 5 7 7 11 12 10
Mac 10 4 6 9 6 4 5 4 10 9 10 9 7 3 9 6 10 13 12 2 4 17 8 9 17 14 7 3 11 14 5 6 8 2 3 7 4 3 3 4 2 2 4 4 1 3
Linux 6 5 6 3 5 1 5 6 1 5 16 8 4 5 13 9 9 8 5 3 1 5 3 8 14 7 5 11 7 5 6 8 3 1 6 6 3 7 3 4 4 1 7 3 4 8

Readme

Source
raw.​githubusercontent.​com

BetterTwig

LICENSE LICENSE Tag Downloads

A Sublime Text package that offers enhanced syntax highlighting, snippets, completions and much more for PHP Twig templates. Read more for the full documentation.

Features

  • Indentation for code blocks.
  • Snippets for common code blocks.
  • Enhanced syntax highlighting for Twig templates.
  • Autocompletions for built in tags, filters, functions, tests & loop variables.

Installation

Package Control

The best way is to install it via Package Control. Once you have Package Control setup in Sublime Text, open the command palette and search for Package Control: Install Package. Search for BetterTwig and install it. Package Control will take care for of automatically updating the package for you if there are new releases.

You can also use Package Control: Add Repository. Copy the github url (without the .git at the end) and enter it into the input panel that pops up at the bottom when you select Package Control: Add Repository. Now use Package Control: Install Package and search for BetterTwig and install it.

Documentation

Key bindings

  • The key bindings are configured so that pressing shift + { twice will automatically add spaces on both sides for the inner brace expression block & place the cursor in the center, like so {{ | }}.
  • |||ly pressing shift + % within {} will add spaces on both sides of the inner % like so {% | %}
  • Use ctrl + / or ctrl + shift + / for Twig comments ({# This is a Twig comment #})

Auto completions

In order to get the auto completions, go to Preferences: Settings from the command palette and paste the following in the Preferences.sublime-settings -- User (the right hand window)

"auto_complete_selector": "text.html.twig, meta.tag - punctuation.definition.tag.begin, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc",
"auto_complete_triggers":
[
    {"characters": "<", "selector": "text.html"},
    {"selector": "text.html.twig, text.html.basic"},
]

If you already have these in your user settings, then just copy the Twig related portions into them.

Snippets

Tab Trigger Twig Code Block
tapply {% apply %}{% endapply %}
tautoescape {% autoescape %}{% endautoescape %}
tblock {% block %}{% endblock %}
tdeprecated {% deprecated %}
tembed {% embed %}{% endembed %}
textends {% extends %}
tfor {% for %}{% endfor %}
tforelse {% for %}{% else %}{% endfor %}
tmacro {% macro %}{% endmacro %}
tsandbox {% sandbox %}{% endsandbox %}
tset {% set %}
tverbatim {% verbatim %}{% endverbatim %}
twith {% with %}{% endwith %}

Issues & Feature requests.

There is always scope for improvements so please do report any bug(s) that you encounter or request for feature(s) that this package should support.

Please follow the issue & feature request templates that have been setup while reporting any bug(s) or requesting for feature(s) (So as to stay as organised as possible).

Use the Twig playground if you want to share a particular snippet of template while creating a specific issue.

License

The MIT License (MIT)

Copyright 2020 © Ashwin Shenoy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.