Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wankdanker/node-templater
Template engine abstraction layer
https://github.com/wankdanker/node-templater
Last synced: 14 days ago
JSON representation
Template engine abstraction layer
- Host: GitHub
- URL: https://github.com/wankdanker/node-templater
- Owner: wankdanker
- Created: 2012-07-19T17:50:40.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-09-15T15:35:55.000Z (over 7 years ago)
- Last Synced: 2024-12-06T05:08:55.722Z (about 1 month ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-templater
--------------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.similar work
------------It seems that @visionmedia's [consolidate.js](https://github.com/visionmedia/consolidate.js) does something similar.
current template engines
-------------
* ejs
* jadeinstall
---------with npm...
```bash
npm install templater
```or with git...
```bash
git clone git://github.com/wankdanker/node-templater.git
```api
----### Templater(options)
the constructor function
### render([template,] options, callback)
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###### options
* *filename* __optional__ - the name of the file to read and process as the template
* *engine* __optional__ - if `filename` is 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 `compile` method.
### end()stop watching any files that are being watched for changes.
example
-------```javascript
var Templater = require('templater')
, t = new Templater()
, context
;context = { name : "Steve Dave" };
t.render({ filename : "test.jade", context : context }, function (err, result) {
console.log(result);t.end();
});
```license
----------### The MIT License (MIT)
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.