Nunjucks
A Sublime Text package for Nunjucks templating engine.
Details
Installs
- Total 12K
- Win 4K
- Mac 7K
- Linux 2K
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 | Sep 14 | Sep 13 | Sep 12 | Sep 11 | Sep 10 | Sep 9 | Sep 8 | Sep 7 | Sep 6 | Sep 5 | Sep 4 | Sep 3 | Sep 2 | Sep 1 | Aug 31 | Aug 30 | Aug 29 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 2 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 3 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
Nunjucks
A Sublime Text package for Nunjucks templating engine.
Features
- enhanced syntax highlighting
- autocompletions for built in tags, filters, functions
- additional snippets
- additional keybindings
- smart indentations
Installation
Via package control (recommended):
- open command palette
- select
Package Control: Install Packages
- search for
Nunjucks
Via GitHub repository:
- open command palette
- select
Package Control: Add Repository
- paste
https://github.com/alsolovyev/Nunjucks
into the field that opens and press enter - open command palette
- select
Package Control: Install Packages
- search for
Nunjucks
* to update the package Package Control: Upgrade Package
select Nunjucks
Manually download sublime-package file:
- download sublime-package file: Nunjucks.sublime-package
- move it into your Sublime Text Installed Packages directory
- Windows:
%APPDATA%\Sublime Text 3\Installed Packages
- OS X:
~/Library/Application\ Support/Sublime\ Text\ 3/Installed\ Packages
- Linux:
~/.config/sublime-text-3/Installed Packages
- Windows:
Manually download repository:
- clone repository
- extract it into your Sublime Text Packages directory
- Windows:
%APPDATA%\Sublime Text 3\Packages
- OS X:
~/Library/Application\ Support/Sublime\ Text\ 3/Packages
- Linux:
~/.config/sublime-text-3/Packages
- Windows:
Documentation
Syntaxes
- Nunjucks - HTML basic
- Nunjucks PHP - with PHP syntax support
Filters
You can create your own filters or use one of the built-in:
abs
- Return the absolute value of the argumentbatch
- Return a list of lists with the given number of itemscapitalize
- Make the first letter uppercasecenter
- Center the value in a field of a given widthdefault
- Return default if value is undefineddictsort
- Sort a dict and yield (key, value) pairsdump
- Call JSON.stringify on an object and dump the result into the templateescape
- Convert the characters &, <, >, ‘, and ” in strings to HTML-safe sequencesfirst
- Get the first item in an array or the first letter if it's a stringfloat
- Convert a value into a floating point numberforceescape
- Enforce HTML escapinggroupby
- Group a sequence of objects by a common attributeindent
- Indent a string using spacesint
- Convert the value into an integerjoin
- Return a string which is the concatenation of the strings in a sequencelast
- Get the last item in an array or the last letter if it's a stringlength
- Return the length of an array or string, or the number of keys in an objectlist
- Convert the value into a listlower
- Convert string to all lower casenl2br
- Replace new lines with<br />
HTML elementsrandom
- Select a random value from an arrayreject
- Filters a sequence of objects by applying a test to each object, and rejecting the objects with the test succeedingrejectattr
- Filter a sequence of objects by applying a test to the specified attribute of each object, and rejecting the objects with the test succeedingreplace
- Replace one item with anotherreverse
- Reverse a stringround
- Round a numbersafe
- Mark the value as safeselect
- Filters a sequence of objects by applying a test to each object, and only selecting the objects with the test succeedingselectattr
- Filter a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeedingslice
- Slice an iterator and return a list of lists containing those itemssort
- Sortarr
with JavaScript'sarr.sort
functionstring
- Convert an object to a stringstriptags
- Strip SGML/XML tags and replace adjacent whitespace by one spacesum
- Output the sum of items in the arraytitle
- Make the first letter of the string uppercasetrim
- Strip leading and trailing whitespacetruncate
- Return a truncated copy of the stringupper
- Convert the string to upper caseurlencode
- Escape strings for use in URLs, using UTF-8 encodingurlize
- Convert URLs in plain text into clickable linkswordcount
- Count and output the number of words in a string
Global Functions
range
- Iterates over a fixed set of numberscycler
- Rotates through several valuesjoiner
- Combines multiple items except for the first time
Snippets
{
- Curly braces for variables%
- Braces for codebl
- Define a section in a templatecb
- BEGIN-END comment blockcl
- Call a macro with all the text inside the tagco
- Braces for commentsext
- “Extends” another templatefl
- Custom filters templatefor
- For loopfr
- Import specific values from a templatefras
- Import specific values from a template and bind to a variableif
- If statementife
- If…Else statementiif
- Inline if statementim
- Import a templateimas
- Import a template and bind to a variableinc
- Include a templatemc
- Define reusable chunks of content(macro)raw
- Output the code inside the tag as plain textset
- Create/modify a variablesetb
- Create/modify a variable(block)
Autocompletions
Currently available completions for all keywords, tags, built-in functions and filters supported by Nunjucks templating engine. Visit the official documentation for more details.
If for some reason the autocomplete popup window does not appear, you need to add text.html.njk
to autocomplete selectors:
- open command palette
- select
Preferences: Settings
- find
auto_complete_selector
- add
text.html.njk
Keybindings
- pressing
shift
+{
twice will turn into{{ | }}
- pressing
shift
+%
within{}
will turn into{% | %}
- pressing
shift
+#
within{}
will turn into{# | #}
Notes
This package was created based on my personal experience with Nunjucks templating engine. Because of what, when writing, I could miss something. Please let me know if you find any inaccuracies or would like to see some additional snippets.
Thank you for downloading this package, and I hope you'll enjoy it.
Links
- Nunjucks templating engine
- Sublime Text community documentation
- Documentation for
.sublime-syntax
files - Documentation for indentation settings
- Documentation for menu
- Documentation for Oniguruma regex engine
- Recommended scope names
- Naming Conventions
License
This project is licensed under the MIT License