{"id":15365642,"url":"https://github.com/tunnckocore/es6-template","last_synced_at":"2025-10-09T10:10:37.956Z","repository":{"id":57227227,"uuid":"42811124","full_name":"tunnckoCore/es6-template","owner":"tunnckoCore","description":"Easy and small template engine for the browser and nodejs.","archived":false,"fork":false,"pushed_at":"2020-07-13T21:38:52.000Z","size":81,"stargazers_count":21,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-09-23T00:56:35.561Z","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/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-20T11:50:32.000Z","updated_at":"2022-03-15T02:18:39.000Z","dependencies_parsed_at":"2022-08-25T12:21:11.426Z","dependency_job_id":null,"html_url":"https://github.com/tunnckoCore/es6-template","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/tunnckoCore/es6-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fes6-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fes6-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fes6-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fes6-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/es6-template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fes6-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001323,"owners_count":26083040,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-01T13:15:23.809Z","updated_at":"2025-10-09T10:10:37.940Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [es6-template][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] \n\n\u003e Small, sync and async es6 template engine, built on top of [gana][] and ES6/ES2015 Template Strings, working on `node@0.10` too!\n\n[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]\n\n## Background\n\nBehind the scenes es6-template uses [gana][] which in turns use [gana-compile][]. So the footprint and codebase is very small (**~1-2kb** minified and not gzipped), easy (just sync and async `.compile` and `.render` methods) and very well tested (this one has **~25 tests**).\n\nWorks well on browsers and even in `node@0.10`. [Read more](https://github.com/tunnckocore/gana#background) on `gana` readme.\n\n## Install\n```\nnpm i es6-template --save\n```\n\n## Usage\n\u003e For more use-cases see the [tests](./test.js)\n\n```js\nconst es6template = require('es6-template')\n```\n\n### [es6template](index.js#L57)\n\u003e Render `template` with `locals` and optionally pass a `cb` callback. If no callback is passed, the rendered `string` is returned. It is alias of and acts like `.render` method.\n\n**Params**\n\n* `\u003ctemplate\u003e` **{String}**: string to be rendered.    \n* `\u003clocals\u003e` **{Object}**: data to be used in `template`.    \n* `[cb]` **{Function}**: callback with `cb(err, res)` signature.    \n* `returns` **{String}**: if no `cb` is passed.  \n\n**Example**\n\n```js\nvar es6template = require('es6-template')\n\nvar template = 'Hello ${ucfirst(author.name)} and have a ${mood} day!'\nvar locals = {\n  author: {\n    name: 'charlike'\n  },\n  mood: 'nice',\n  ucfirst: function ucfirst (val) {\n    return val.charAt(0).toUpperCase() + val.slice(1)\n  }\n}\n\n// synchronous\nvar str = es6template(template, locals)\nconsole.log(str)\n// =\u003e 'Hello Charlike and have a nice day!'\n\n// async\nes6template(template, locals, function cb (err, res) {\n  if (err) return console.error(err)\n\n  console.log(res)\n  // =\u003e 'Hello Charlike and have a nice day!'\n})\n```\n\n### [.compile](index.js#L104)\n\u003e Compile a `template` to a function that can accept `locals` object to render a string. If `cb` is passed, it pass a `compileFn` as result. It's a [gana][] mirror, so if there's a problem, so please report it in the [gana][]'s issue tracker.\n\n**Params**\n\n* `\u003ctemplate\u003e` **{String}**: string to be compile to a function.    \n* `[cb]` **{Function}**: callback with `cb(err, compileFn)` signature.    \n* `returns` **{Function}**: if no `cb` is passed.  \n\n**Example**\n\n```js\nvar es6template = require('es6-template')\n\nvar template = 'You, ${uppercase(name)}, are awesome ${person}!'\nvar locals = {\n  name: 'charlike',\n  person: 'developer',\n  uppercase: function uppercase (val) {\n    return val.toUpperCase()\n  }\n}\n\n// sync\nvar compileFn = es6template.compile(template)\nvar result = compileFn(locals)\nconsole.log(result)\n// =\u003e 'You, CHARLIKE, are awesome developer!'\n\n// asynchronous, gives you `compileFn` in the callback\nes6template(template, function cb (err, compileFn) {\n  if (err) return console.error(err)\n\n  var result = compileFn(locals)\n  console.log(result)\n  // =\u003e 'You, CHARLIKE, are awesome developer!'\n})\n```\n\n### [.render](index.js#L134)\n\u003e Renders a `template` with `locals`. If no `cb` is passed, returns a rendered string, otherwise pass the result to `cb` callback function. Acts like a `es6template()` which is mirror of this one. If there are some problems, please report them to the [gana][] or [gana-compile][] issue trackers, because this basically is `gana(template)(locals)`.\n\n**Params**\n\n* `\u003ctemplate\u003e` **{String}**: string to be rendered.    \n* `\u003clocals\u003e` **{Object}**: data to be used in `template`.    \n* `[cb]` **{Function}**: callback with `cb(err, res)` signature.    \n* `returns` **{String}**: if no `cb` is passed.  \n\n**Example**\n\n```js\nvar es6template = require('es6-template')\n\nvar str = es6template.render('Hello ${name}.', { name: 'Charlike' })\nconsole.log(str)\n// =\u003e 'Hello Charlike.'\n```\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/es6-template/issues/new).  \nBut before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.\n\n## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]\n\n[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]\n\n[gana-compile]: https://github.com/tunnckocore/gana-compile\n[gana]: https://github.com/tunnckocore/gana\n\n[npmjs-url]: https://www.npmjs.com/package/es6-template\n[npmjs-img]: https://img.shields.io/npm/v/es6-template.svg?label=es6-template\n\n[license-url]: https://github.com/tunnckoCore/es6-template/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/es6-template.svg\n\n[downloads-url]: https://www.npmjs.com/package/es6-template\n[downloads-img]: https://img.shields.io/npm/dm/es6-template.svg\n\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/es6-template\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/es6-template.svg\n\n[travis-url]: https://travis-ci.org/tunnckoCore/es6-template\n[travis-img]: https://img.shields.io/travis/tunnckoCore/es6-template/master.svg\n\n[coveralls-url]: https://coveralls.io/r/tunnckoCore/es6-template\n[coveralls-img]: https://img.shields.io/coveralls/tunnckoCore/es6-template.svg\n\n[david-url]: https://david-dm.org/tunnckoCore/es6-template\n[david-img]: https://img.shields.io/david/tunnckoCore/es6-template.svg\n\n[standard-url]: https://github.com/feross/standard\n[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n\n[author-www-url]: http://www.tunnckocore.tk\n[author-www-img]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg\n\n[keybase-url]: https://keybase.io/tunnckocore\n[keybase-img]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg\n\n[author-npm-url]: https://www.npmjs.com/~tunnckocore\n[author-npm-img]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg\n\n[author-twitter-url]: https://twitter.com/tunnckoCore\n[author-twitter-img]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg\n\n[author-github-url]: https://github.com/tunnckoCore\n[author-github-img]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg\n\n[freenode-url]: http://webchat.freenode.net/?channels=charlike\n[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg\n\n[new-message-url]: https://github.com/tunnckoCore/ama\n[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fes6-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftunnckocore%2Fes6-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftunnckocore%2Fes6-template/lists"}