{"id":18337235,"url":"https://github.com/pillarjs/templation","last_synced_at":"2025-04-06T04:36:15.642Z","repository":{"id":18255996,"uuid":"21412232","full_name":"pillarjs/templation","owner":"pillarjs","description":"[ON HOLD] an asynchronous, extensible view system","archived":false,"fork":false,"pushed_at":"2014-09-11T23:24:23.000Z","size":151,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-21T17:37:18.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pillarjs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T05:13:01.000Z","updated_at":"2025-03-04T10:52:43.000Z","dependencies_parsed_at":"2022-09-14T01:25:27.043Z","dependency_job_id":null,"html_url":"https://github.com/pillarjs/templation","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pillarjs%2Ftemplation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pillarjs%2Ftemplation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pillarjs%2Ftemplation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pillarjs%2Ftemplation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pillarjs","download_url":"https://codeload.github.com/pillarjs/templation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247435038,"owners_count":20938530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T20:10:33.186Z","updated_at":"2025-04-06T04:36:10.627Z","avatar_url":"https://github.com/pillarjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# templation\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\nA node.js view system similar to what you're used to with Express' `res.render()`.\nInspired by [co-views](https://github.com/visionmedia/co-views) and\n[consolidate.js](https://github.com/visionmedia/consolidate.js/).\n\n- First-class async support. `.render()` always returns a Promise.\n- Streams are supported.\n- Template adapters are integrated, but are retrieved lazily to avoid code bloat.\n- Easier plugin system for custom renderers.\n\n### Install\n\n```bash\n$ npm install templation\n```\n\n## API\n\n```js\nvar Templation = require('templation')\nvar views = new Templation()\n\nviews.use('html', Templation.engines.html)\n```\n\n### var views = new Templation(options)\n\nCreate a new view system.\nOptions are:\n\n- `cache` - whether to cache the templates.\n  Defaults to `true` in production.\n- `root` - the root folder to look for templates.\n  Defaults to `process.cwd()`, so __you should set this__.\n\n#### views.use(extension, engine)\n\nUse a custom view engine.\n`extension` is a file extension to map this engine to.\n`engine` is an object with the following methods:\n\n- `.compile(filename, options)` - it should return (optionally via promise)\n  a \"compiled template\". The \"compiled template\" must be an object or function.\n  This gets cached when `cache: true`!\n- `.render(compiled, options)` - `compiled` is whatever is compiled from `.compile()`.\n  It should return (optionally via promise) a `String`, `Buffer`, or `Stream`\n\n#### views.render(name, options)\n\nRender the template `name`, which resolves against `root`.\nReturns a promise, which then returns a `String`, `Buffer`, or `Stream`.\n\n#### views.cache\n\nEnable or disable the caching system. (`true` / `false`)\n\n### Templation.engines\n\nA list of included engines.\nGenerally, the API usage is:\n\n```js\nviews.use('html', Templation.engines.html)\n```\n\nIncluded adapters are:\n\n- [jade](http://jade-lang.com)\n- [then-jade](https://github.com/then/then-jade) - for streaming templates\n- [swig](http://paularmstrong.github.io/swig/)\n- html - just returns the file\n\n## Examples\n\n```js\nvar Templation = require('templation')\nvar views = new Templation()\nviews.use('html', Templation.engines.html)\n\nhttp.createServer(function (req, res) {\n  views.render('home').then(function (html) {\n    // assuming html is a string\n    res.setHeader('Content-Length', Buffer.byteLength(html))\n    res.setHeader('Content-Type', 'text/html')\n    res.end(html)\n  }, function (err) {\n    res.statusCode = err.status || 500\n    res.end('Internal Server Error')\n  })\n})\n```\n\n## [License (MIT)](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/templation.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/templation\n[github-tag]: http://img.shields.io/github/tag/pillarjs/templation.svg?style=flat-square\n[github-url]: https://github.com/pillarjs/templation/tags\n[travis-image]: https://img.shields.io/travis/pillarjs/templation.svg?style=flat-square\n[travis-url]: https://travis-ci.org/pillarjs/templation\n[coveralls-image]: https://img.shields.io/coveralls/pillarjs/templation.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/pillarjs/templation?branch=master\n[david-image]: http://img.shields.io/david/pillarjs/templation.svg?style=flat-square\n[david-url]: https://david-dm.org/pillarjs/templation\n[license-image]: http://img.shields.io/npm/l/templation.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/templation.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/templation\n[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square\n[gittip-url]: https://www.gittip.com/jonathanong/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpillarjs%2Ftemplation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpillarjs%2Ftemplation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpillarjs%2Ftemplation/lists"}