GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing mozilla.github.io — Nunjucks Nunjucks
A rich and powerful templating language for JavaScript.
x
BrowserGrab nunjucks.js (min) for the full library, or grab nunjucks-slim.js (min) for a slim version that only works with precompiled templates. Read more about the differences of these files in Getting Started.
You've been looking for a more sophisticated templating
engine for JavaScript. Here it is.
{% extends "base.html" %}
{% block header %}
<h1>{{ title }}</h1>
{% endblock %}
{% block content %}
<ul>
{% for name, item in items %}
<li>{{ name }}: {{ item }}</li>
{% endfor %}
</ul>
{% endblock %}
Who's Using It?Firefox Marketplace
Mozilla Webmaker
Apostrophe CMS
More Examples
Use any of the builtin filters to work with variables, and
even create your own.
{{ foo | title }}
{{ foo | join(",") }}
{{ foo | replace("foo", "bar") | capitalize }}
Use keyword arguments to any function or filter
{{ foo(1, 2, bar=3, baz=4) }}
{{ bar | transform(level=2) }}
Template inheritance allows you to reuse templates in a powerful
way. Define skeleton structures that child templates fill in.
{% extends "base.html" %}
{% block header %}
<h3>{{ subtitle }}</h3>
{% endblock %}
{% block content %}
<h1>{{ page.title }}</h1>
<p>{{ page.content }}</p>
{% endblock %}
You can even write asynchronous templates if you need to make
asynchronous calls in filters! Take advantage
of
asyncAll
to execute all iterations in parallel,
assuming lookup is asynchronous.
<h1>Posts</h1>
<ul>
{% asyncAll item in items %}
<li>{{ item.id | lookup }}</li>
{% endall %}
</ul>
That's just the beginning. Check the the docs for a whole range of powerful features! |
| You are visitor 01402605 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |