swig extensions
Tags, filters, and extensions for Swig, the most awesome template engine for node.js.
This project is based on (and complementary to) swig-extras, from @paularmstrong
Getting started
Use a filter:
var swig = ;var extensions = ; extensions;
Use a tag:
var swig = ;var extensions = ;var mySwig = ; extensions;
Available Filters
- condense
- markdown (using Marked)
- prettify
Available Tags
- markdown
- prettify
Usage with Assemble
assemble-swig
1. Installnpm install assemble-swig --save-dev
Once the assemble-swig engine has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt;
2. Add swig to assemble
Specify swig
as the current engine for processing templates:
assemble: options: engine: 'swig'
3. Add swig tags and filters
Specify the path or paths (optionally using minimatch patterns) to the helpers
property in the Assemble options:
assemble: options: engine: 'swig' helpers: 'src/extensions/*.js'
load them as modules
For Assemble to find and register your custom tags and filters, you must export them either as objects or functions inside a module.exports
object:
moduleexports { // filters and tags};
Example of how to register multiple filters as properties of the filters
object:
var filters = moduleexports = {}; filters { return input;}; filters { return input;}; filters { return input;}; moduleexports { opts = opts || {}; // filters.useFilter(swig, filters); for var filter in filters if filters swig; };
Related projects
- assemble (see the live docs)
- assemble-swig
- assemble-swig-examples
License
Licensed under the MIT License (MIT)
Copyright (c) 2013 Jon Schlinkert