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

Nunjucks

by alsolovyev ST3

A Sublime Text package for Nunjucks templating engine.

Details

Installs

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

Readme

Source
raw.​githubusercontent.​com

Nunjucks

A Sublime Text package for Nunjucks templating engine.

LICENSE LICENSE Tag Downloads

Nunjucks

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

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

Documentation

Syntaxes

Filters

You can create your own filters or use one of the built-in:

  • abs - Return the absolute value of the argument
  • batch - Return a list of lists with the given number of items
  • capitalize - Make the first letter uppercase
  • center - Center the value in a field of a given width
  • default - Return default if value is undefined
  • dictsort - Sort a dict and yield (key, value) pairs
  • dump - Call JSON.stringify on an object and dump the result into the template
  • escape - Convert the characters &, <, >, , and in strings to HTML-safe sequences
  • first - Get the first item in an array or the first letter if it's a string
  • float - Convert a value into a floating point number
  • forceescape - Enforce HTML escaping
  • groupby - Group a sequence of objects by a common attribute
  • indent - Indent a string using spaces
  • int - Convert the value into an integer
  • join - Return a string which is the concatenation of the strings in a sequence
  • last - Get the last item in an array or the last letter if it's a string
  • length - Return the length of an array or string, or the number of keys in an object
  • list - Convert the value into a list
  • lower - Convert string to all lower case
  • nl2br - Replace new lines with <br /> HTML elements
  • random - Select a random value from an array
  • reject - Filters a sequence of objects by applying a test to each object, and rejecting the objects with the test succeeding
  • rejectattr - Filter a sequence of objects by applying a test to the specified attribute of each object, and rejecting the objects with the test succeeding
  • replace - Replace one item with another
  • reverse - Reverse a string
  • round - Round a number
  • safe - Mark the value as safe
  • select - Filters a sequence of objects by applying a test to each object, and only selecting the objects with the test succeeding
  • selectattr - Filter a sequence of objects by applying a test to the specified attribute of each object, and only selecting the objects with the test succeeding
  • slice - Slice an iterator and return a list of lists containing those items
  • sort - Sort arr with JavaScript's arr.sort function
  • string - Convert an object to a string
  • striptags - Strip SGML/XML tags and replace adjacent whitespace by one space
  • sum - Output the sum of items in the array
  • title - Make the first letter of the string uppercase
  • trim - Strip leading and trailing whitespace
  • truncate - Return a truncated copy of the string
  • upper - Convert the string to upper case
  • urlencode - Escape strings for use in URLs, using UTF-8 encoding
  • urlize - Convert URLs in plain text into clickable links
  • wordcount - Count and output the number of words in a string

Global Functions

  • range - Iterates over a fixed set of numbers
  • cycler - Rotates through several values
  • joiner - Combines multiple items except for the first time

Snippets

  • { - Curly braces for variables
  • % - Braces for code
  • bl - Define a section in a template
  • cb - BEGIN-END comment block
  • cl - Call a macro with all the text inside the tag
  • co - Braces for comments
  • ext - “Extends” another template
  • fl - Custom filters template
  • for - For loop
  • fr - Import specific values from a template
  • fras - Import specific values from a template and bind to a variable
  • if - If statement
  • ife - If…Else statement
  • iif - Inline if statement
  • im - Import a template
  • imas - Import a template and bind to a variable
  • inc - Include a template
  • mc - Define reusable chunks of content(macro)
  • raw - Output the code inside the tag as plain text
  • set - Create/modify a variable
  • setb - 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

License

This project is licensed under the MIT License