Nova

Extensions


Readme

Twig for Nova

This extension for Nova, a text editor from Panic, adds syntax highlighting for Twig, a popular templating language. It supports all relevant language features from Twig 3.0+ and even some custom tags/filters from Craft CMS 3.0+.

This extension also includes completions for Twig and Craft CMS 3.0+.

Installation

In Nova, go to “Extension > Extensions Library”, search for “Twig” and install the extension.

Manual way: Download this repository, extract the .zip file and open the folder with Nova.

Development

Clone this repository and open the folder with Nova. In Nova, go to “Settings > General” and enable “Show extension development items in the Extension menu”. Then activate the extension via the “Extension” menu.

What’s next?

I’d like to add more features to this extension in the future:

  • [ ] Add support for nested syntax highlighting inside {% css %} and {% js %}
  • [ ] Add support for matching Twig brackets (not possible at the moment?)
  • [ ] Improve completions

If you have some tips or want to help with development, feel free to let me know!


Changelog

Version 1.4.1

  • Fix: Don’t show syntax highlighting inside comments

Version 1.4

  • Add symbols for macro definitions
  • Add completions for variables and macros defined in the same file
  • Add completions for argument lists

Version 1.3

  • Add basic tag completions for Twig-HTML (outside opening brackets)
  • Fix: correct end tag for autoescape completion
  • Fix: correct syntax highlighting for blocks and variables named like keywords

Version 1.2

  • Auto insert %} after tags in completions
  • Auto insert {% endif %}, {% endfor %} etc. in tag completions
  • Auto insert space after function calls in completions
  • Improve context for completions
  • Remove matching {} from Twig-HTML syntax

Version 1.1

  • Completions for Craft CMS 3.0+
  • Better Syntax Highlighting for Craft CMS 3.0+
  • Better Icon

Version 1.0

Initial release

  • Syntax Highlighting for Twig 3.0+
  • Syntax Highlighting for custom tags/filters from Craft CMS 3.0+
  • Completions for Twig 3.0+

License

MIT License

Copyright (c) 2020

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.