Nunjucks Extended ======
A Better Nunjucks Syntax Highlighter for Sublime Text
- Open up Sublime Text
- Press
shift+ctrl+p
and type inPackage Controll:
- Then Type in
Install Package
and Press Enter - Search for
Nunjucks Extended
and Press Enter - Restart Sublime Text And Enjoy!
- Change directories into your Packages Directory
- Windows
$env:appdata\Sublime Text 3\Packages\
- Mac
~/Library/Application\ Support/Sublime\ Text\ 3/Packages/
- Linux
cd .config/sublime-text-3/Packages/
- Windows
git clone http://github.com/thecodechef/nunjucks-extended.git
- Restart Sublime Text and Enjoy!
- First off create a fork of this repo
- then in your terminal type
cd git clone http://github.com/[your-username]/nunjucks-extended.git [path-to-place-repo]
- to create a feature branch:
git checkout -b my-feature-branch
Tag Blocks ++++++
{% set links = [ "../css/bootstrap.min.css", "../css/font-awesome.min.css", "..css/main.min.css" ] %} {% asyncAll link in links %} <link rel="stylesheet" href=link /> {% endasyncAll %} //=> <link rel"stylesheet" href="../css/bootstrap.min.css"/> //=> <link rel"stylesheet" href="../css/font-awesome.min.css"/> //=> <link rel"stylesheet" href="../css/main.min.css"/>
{% set links = [ "../css/bootstrap.min.css", "../css/font-awesome.min.css", "..css/main.min.css" ] %} {% asyncEach link in links %} <link rel="stylesheet" href=link /> {% endasyncEach %} //=> <link rel"stylesheet" href="../css/bootstrap.min.css"/> //=> <link rel"stylesheet" href="../css/font-awesome.min.css"/> //=> <link rel"stylesheet" href="../css/main.min.css"/>
{% set name = "Jeremy" %} {% block content %} Hello, {{ name }} {% endblock %} //=> Hello, Jeremy
{% call add(1, 2) -%} The result is {%- endcall %} //=> The result is: 3
Filter Tag Example ################# .. code:: jinja
{% filter replace("force","forth") %} may the force be with you {% endfilter %}
//=> may the forth be with you
{% set items = ["Nunjucks is Awesome"] %} <h1>Posts</h1> <ul> {% for item in items %} <li>{{ item.title }}</li> {% else %} <li>Nothing to Show</li> {% endfor %} </ul>
//=> <h1>Posts</h1> //=> <ul> //=> <li>Nunjucks is Awesome<li> //=> </ul>
{% set isActive = true %} {% if isActive %} <li class="active">Link</li> {% elif isActive !== true or false %} <li>Undefined</li> {% else %} <li>Link<li> {% endif %} //=> <li class="active">Link</>
{% macro add(x,y) %} <p>{{ caller() }}: {{ x + y }}</p> {% endmacro %}
{% raw %} {{ name }} {% endraw %} //=> {{ name }}
Inline Tags ++++++
{% extends "_layouts/default.njk" %} {% block content %} {% endblock %}
{% import "_macros/navbar.njk" %} {% import "_macros/navbar.njk" as navbar %} {% from "_macros/navbar.njk" import navItem %} {% from "_macros/navbar.njk" import navItem,activeNavItem as activeItem %}
{% include "_partials/modal.njk" %} {% include "_partials/modal.njk" ignore missing %}