given a swig template, create a dummy context which is useful for template composing tools

npm install swig-dummy-context
2 downloads in the last day
16 downloads in the last week
97 downloads in the last month


Given a swig template, produce a dummy context that you can immediately use to preview your template.

See also swig-email-templates

Example Usage

Contents of template.html:

  {{ description }}
{% if articles %}
  {% for article in articles %}
    <li>{{ article.name }}</li>
  {% endfor %}
{% else %}
  <p>{{ defaultText }}</p>
{% endif %}
var swig = require('swig')
  , createDummyContext = require('swig-dummy-context')

  allowErrors: true,
  root: path.join(__dirname, "templates"),
var template = swig.compileFile("template.html");
assert.deepEqual(createDummyContext(template), {
  "description": "description",
  "articles": {
    "name": "name",
  "defaultText": "defaultText"
npm loves you