Template engine abstraction layer plus caching, change watching, file loading
An abstraction layer for template engines. This module attempts to bring together as many template engines as possible into a single uniform api which provides the additional features of caching, loading templates from files and watching template files for changes.
It seems that @visionmedia's consolidate.js does something similar.
npm install templater
or with git...
git clone git://github.com/wankdanker/node-templater.git
the constructor function
render the optional
template string or
filename specified on the options object
- template optional - template string to process
- options required - option object
- callback required - callback function
- filename optional - the name of the file to read and process as the template
- engine optional - if
filenameis specified, the engine will be automatically determined based on the filename's extension. Otherwise specify which engine to use eg: ejs, jade, etc.
- context required - the data object to pass to the template engine. This provides the context within your template.
All other attributes of the
options object are passed to template engines
stop watching any files that are being watched for changes.
var Templater = require'templater't =context;context = name : "Steve Dave" ;trender filename : "test.jade" context : contextconsole.logresult;tend;;
Copyright (c) 2012 Daniel L. VerWeire
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.