{"id":18429445,"url":"https://github.com/bigpipe/temper","last_synced_at":"2025-09-01T04:39:56.657Z","repository":{"id":9586918,"uuid":"11504476","full_name":"bigpipe/temper","owner":"bigpipe","description":"Temper compiles your templates for client and server side usage.","archived":false,"fork":false,"pushed_at":"2020-10-26T13:12:21.000Z","size":60,"stargazers_count":20,"open_issues_count":3,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-18T21:45:53.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bigpipe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2013-07-18T14:12:10.000Z","updated_at":"2020-10-26T13:12:24.000Z","dependencies_parsed_at":"2022-08-31T22:40:54.884Z","dependency_job_id":null,"html_url":"https://github.com/bigpipe/temper","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Ftemper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Ftemper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Ftemper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigpipe%2Ftemper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigpipe","download_url":"https://codeload.github.com/bigpipe/temper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247697991,"owners_count":20981283,"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-06T05:17:11.138Z","updated_at":"2025-04-07T17:33:04.283Z","avatar_url":"https://github.com/bigpipe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Temper\n\n[![Version npm][version]](http://browsenpm.org/package/temper)[![Build Status][build]](https://travis-ci.org/bigpipe/temper)[![Dependencies][david]](https://david-dm.org/bigpipe/temper)[![Coverage Status][cover]](https://coveralls.io/r/bigpipe/temper?branch=master)\n\n[from]: https://img.shields.io/badge/from-bigpipe.io-9d8dff.svg?style=flat-square\n[version]: http://img.shields.io/npm/v/temper.svg?style=flat-square\n[build]: http://img.shields.io/travis/bigpipe/temper/master.svg?style=flat-square\n[david]: https://img.shields.io/david/bigpipe/temper.svg?style=flat-square\n[cover]: http://img.shields.io/coveralls/bigpipe/temper/master.svg?style=flat-square\n\nTemper is a small module that compiles your templates for server-side usage and\nclient-side usage through one single interface. This makes it easy to create\nisomorphic JavaScript applications, which is awesome.\n\nThe following template engines are supported:\n\n- **react-jsx**, automatically discovered by using the `.jsx` extension.\n- **jade**, automatically discovered by using the `.jade` extension.\n- **ejs**, automatically discovered by using the `.ejs` extension.\n- **hogan.js**, automatically discovered by using the `.mustache` extension.\n- **mustache**, automatically discovered by using the `.mustache` extension.\n- **handlebars**, automatically discovered by using the `.mustache` extension.\n- **html**, automatically discovered by using the `.html` extension.\n\nAs you can see from the list above, we support multiple version engines for the\n`mustache` extension. You can supply your preference through the API. If no\npreference is given it will iterate over the template engines and the one that\nis successfully required will be used automatically.\n\n### Installation\n\nTemper is distributed through npm:\n\n```\nnpm install --save temper\n```\n\n### Usage\n\nTemper doesn't depend on any template engines so you need to install these your\nself. For these examples I'm going to assume that you have `jade` installed as\ntemplate engine. Run `npm install --save jade` if this is not the case.\n\nInitialising temper is quite simple:\n\n```js\n'use strict';\n\nvar Temper = require('temper')\n  , temper = new Temper();\n```\n\nThe `Temper` constructor allows the following options:\n\n- `cache` should we cache the compiled template, this defaults to `true` if\n  `NODE_ENV` is set to `production`. You usually want to have this disabled during\n  development so you can see the changes in your template without having to\n  restart your node process.\n\nThe following methods can be used to interact with `temper`:\n\n##### temper.fetch(file, [engine])\n\nThe `temper.fetch` method allows you to pre-compile your template file. This\nis advised as requiring modules and reading files is done synchronous. Simply\ncall this method with a file location and an option engine argument.\n\nTemper will try it's best to automatically discover template engines based on\nfile extensions, but sometimes this is impossible. There are tons of `mustache`\ncompatible template engines and we cannot figure out which one you want based on\nthe extension. But for template languages such as `jade` it's quite simple.\n\n```js\nvar data = temper.prefetch('/file/path/to/template.jade');\nvar data = temper.prefetch('/file/path/to/template.mustache', 'hogan.js');\n```\n### Data structure\n\nThe fetch method returns an JavaScript object that contains the following\nproperties:\n\n\u003cdl\u003e\n  \u003cdt\u003elibrary\u003c/dt\u003e\n  \u003cdd\u003e\n    This is an optional property. Some of the supported engines require a helper\n    library to be included at the client-side. If this property is not empty you\n    should include this string together with your client side template on your\n    page.\n  \u003c/dd\u003e\n\n  \u003cdt\u003eclient\u003c/dt\u003e\n  \u003cdd\u003e\n    The client-side compatible version of your given template. This is already\n    converted to a string for your convenience.\n  \u003c/dd\u003e\n\n  \u003cdt\u003eserver\u003c/dt\u003e\n  \u003cdd\u003e\n    The server-side compatible version of your given template. It's a function\n    that's ready to be used.\n  \u003c/dd\u003e\n\n  \u003cdt\u003eengine\u003c/dt\u003e\n  \u003cdd\u003e\n    The name of the template engine that was used to compile your template.\n  \u003c/dd\u003e\n\n  \u003cdt\u003ehash\u003c/dt\u003e\n  \u003cdd\u003e\n    An object that contains the hashes for the library, client and server.\n  \u003c/dd\u003e\n\u003c/dl\u003e\n\n### The interface\n\nThe resulting compiled template have a uniform interface. It's a function that\naccepts the template data as first argument and returns the generated template.\n\n```js\nvar template = temper.fetch('/file/path/to/template.jade')\n  , html = template({ foo: 'bar' });\n\nconsole.log(html);\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigpipe%2Ftemper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigpipe%2Ftemper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigpipe%2Ftemper/lists"}