├── .editorconfig ├── .gitignore ├── .travis.yml ├── .verb.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── dist ├── es6-template.js ├── es6-template.min.js ├── es6-template.min.js.map ├── es6-template.standalone.js ├── es6-template.standalone.min.js └── es6-template.standalone.min.js.map ├── index.js ├── package.json ├── renovate.json ├── test.js └── test ├── compile-async.js ├── compile-sync.js ├── main-async.js ├── main-sync.js ├── render-async.js └── render-sync.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | insert_final_newline = false 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Always-ignore dirs # 2 | # #################### 3 | _gh_pages 4 | node_modules 5 | jspm_packages 6 | bower_components 7 | components 8 | vendor 9 | build 10 | dest 11 | src 12 | lib-cov 13 | coverage 14 | nbproject 15 | cache 16 | temp 17 | tmp 18 | es6-template 19 | 20 | # Packages # 21 | # ########## 22 | *.7z 23 | *.dmg 24 | *.gz 25 | *.iso 26 | *.jar 27 | *.rar 28 | *.tar 29 | *.zip 30 | 31 | # OS, Logs and databases # 32 | # ######################### 33 | logs 34 | *.pid 35 | *.dat 36 | *.log 37 | *.sql 38 | *.sqlite 39 | *~ 40 | ~* 41 | 42 | # Another files # 43 | # ############### 44 | Icon? 45 | .DS_Store* 46 | Thumbs.db 47 | ehthumbs.db 48 | Desktop.ini 49 | npm-debug.log 50 | .directory 51 | ._* 52 | lcov.info 53 | 54 | # Runtime data 55 | pids 56 | *.pid 57 | *.seed 58 | *.pid.lock 59 | 60 | 61 | # nyc test coverage 62 | .nyc_output 63 | 64 | # Grunt intermediate storage 65 | # see here: http://gruntjs.com/creating-plugins#storing-task-files 66 | .grunt 67 | 68 | # Optional npm cache directory 69 | .npm 70 | 71 | # Optional REPL history 72 | .node_repl_history 73 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | 4 | node_js: 5 | - "node" 6 | - "6" 7 | - "5" 8 | - "4" 9 | - "0.12" 10 | - "0.10" 11 | 12 | matrix: 13 | fast_finish: true 14 | allow_failures: 15 | - node_js: "4" 16 | - node_js: "0.10" 17 | - node_js: "0.12" 18 | 19 | notifications: 20 | email: false 21 | 22 | after_success: npm run report-coverage 23 | -------------------------------------------------------------------------------- /.verb.md: -------------------------------------------------------------------------------- 1 | # [{%= name %}][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] 2 | 3 | > {%= description %} 4 | 5 | [![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] 6 | 7 | ## Background 8 | 9 | 10 | ${locals.name}$ 11 | 12 | Behind the scenes {%= name %} 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**). 13 | 14 | Works well on browsers and even in `node@0.10`. [Read more](https://github.com/tunnckocore/gana#background) on `gana` readme. 15 | 16 | ## Install 17 | ``` 18 | npm i {%= name %} --save 19 | ``` 20 | 21 | ## Usage 22 | > For more use-cases see the [tests](./test.js) 23 | 24 | ```js 25 | const es6template = require('{%= name %}') 26 | ``` 27 | 28 | {%= apidocs('index.js') %} 29 | 30 | ${ 31 | verb.related && verb.related.list && verb.related.list.length 32 | ? related(verb.related.list, { word: 12 }) 33 | : '' 34 | }$ 35 | 36 | {% if (verb.related && verb.related.list && verb.related.list.length) { %} 37 | ## Related 38 | {%= related(verb.related.list, {words: 12}) %} 39 | {% } %} 40 | 41 | ## Contributing 42 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/{%= repository %}/issues/new). 43 | But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines. 44 | 45 | ## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url] 46 | 47 | [![{%= author.username %}.tk][author-www-img]][author-www-url] [![keybase {%= author.username %}][keybase-img]][keybase-url] [![{%= author.username %} npm][author-npm-img]][author-npm-url] [![{%= author.username %} twitter][author-twitter-img]][author-twitter-url] [![{%= author.username %} github][author-github-img]][author-github-url] 48 | 49 | {%= reflinks(verb.reflinks) %} 50 | 51 | [npmjs-url]: https://www.npmjs.com/package/{%= name %} 52 | [npmjs-img]: https://img.shields.io/npm/v/{%= name %}.svg?label={%= name %} 53 | 54 | [license-url]: https://github.com/{%= repository %}/blob/master/LICENSE 55 | [license-img]: https://img.shields.io/npm/l/{%= name %}.svg 56 | 57 | [downloads-url]: https://www.npmjs.com/package/{%= name %} 58 | [downloads-img]: https://img.shields.io/npm/dm/{%= name %}.svg 59 | 60 | 61 | [codeclimate-url]: https://codeclimate.com/github/{%= repository %} 62 | [codeclimate-img]: https://img.shields.io/codeclimate/github/{%= repository %}.svg 63 | 64 | [travis-url]: https://travis-ci.org/{%= repository %} 65 | [travis-img]: https://img.shields.io/travis/{%= repository %}/master.svg 66 | 67 | [coveralls-url]: https://coveralls.io/r/{%= repository %} 68 | [coveralls-img]: https://img.shields.io/coveralls/{%= repository %}.svg 69 | 70 | [david-url]: https://david-dm.org/{%= repository %} 71 | [david-img]: https://img.shields.io/david/{%= repository %}.svg 72 | 73 | [standard-url]: https://github.com/feross/standard 74 | [standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg 75 | 76 | 77 | [author-www-url]: http://www.{%= author.username.toLowerCase() %}.tk 78 | [author-www-img]: https://img.shields.io/badge/www-{%= author.username.toLowerCase() %}.tk-fe7d37.svg 79 | 80 | [keybase-url]: https://keybase.io/{%= author.username.toLowerCase() %} 81 | [keybase-img]: https://img.shields.io/badge/keybase-{%= author.username.toLowerCase() %}-8a7967.svg 82 | 83 | [author-npm-url]: https://www.npmjs.com/~{%= author.username.toLowerCase() %} 84 | [author-npm-img]: https://img.shields.io/badge/npm-~{%= author.username.toLowerCase() %}-cb3837.svg 85 | 86 | [author-twitter-url]: https://twitter.com/{%= author.username %} 87 | [author-twitter-img]: https://img.shields.io/badge/twitter-@{%= author.username %}-55acee.svg 88 | 89 | [author-github-url]: https://github.com/{%= author.username %} 90 | [author-github-img]: https://img.shields.io/badge/github-@{%= author.username %}-4183c4.svg 91 | 92 | [freenode-url]: http://webchat.freenode.net/?channels=charlike 93 | [freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg 94 | 95 | [new-message-url]: https://github.com/{%= author.username %}/ama 96 | [new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## 1.0.3 - 2015-10-15 4 | - Release v1.0.3 / npm@v1.0.3 5 | - use `lazy-cache` - add `utils.js` for browserify-friendly lazyness 6 | 7 | ## 1.0.2 - 2015-10-15 8 | - Release v1.0.2 / npm@v1.0.2 9 | - update travis 10 | - add one more test 11 | - merge #1 - render empty strings like ES6 does 12 | 13 | ## 1.0.1 - 2015-10-01 14 | - Release v1.0.1 / npm@v1.0.1 15 | - update and docs 16 | 17 | ## 1.0.0 - 2015-09-21 18 | - Release v1.0.0 / npm@v1.0.0 19 | - update keywords 20 | - update tests 21 | - add related 22 | - docs 23 | - escaping 24 | 25 | ## 0.1.0 - 2015-09-20 26 | - publish on npm as 0.1.0 27 | - update readme 28 | - implement :cat2: 29 | 30 | ## 0.0.0 - 2015-09-20 31 | - Initial commit -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to es6-template 2 | 3 | :sparkles: Thanks for your contribution in advance! :tada: 4 | 5 | First and foremost, thank you! We appreciate that you want to contribute to `es6-template`, your time is valuable, and your contributions mean a lot to us. 6 | 7 | ## What does "contributing" mean? 8 | 9 | There are many ways to contribute to an open source project, including: 10 | 11 | - Updating or correcting documentation 12 | - Feature requests 13 | - Submitting bug reports 14 | 15 | But you aren't limited to these things. Use your imagination. If you like a project, and you see something that can or should be improved, then you have an opportunity (but not an obligation) to contribute. 16 | 17 | ### Improve documentation 18 | 19 | As a user of `es6-template` you're the perfect candidate to help us improve our documentation. Typo corrections, error fixes, better explanations, more examples, etc. Open issues for things that could be improved. Anything. Even improvements to this document. 20 | 21 | Use the [`docs` label](https://github.com/tunnckoCore/es6-template/labels/docs) to find suggestions for what we'd love to see more documentation on. 22 | 23 | ### Improve issues 24 | 25 | Some issues are created with missing information, not reproducible, or plain invalid. Help make them easier to resolve. Handling issues takes a lot of time that we could rather spend on fixing bugs and adding features. 26 | 27 | ### Give feedback on issues 28 | 29 | We're always looking for more opinions on discussions in the issue tracker. It's a good opportunity to influence the future direction of AVA. 30 | 31 | The [`question` label](https://github.com/tunnckoCore/es6-template/labels/question) is a good place to find ongoing discussions. 32 | 33 | 34 | ## Why should I contribute? 35 | 36 | Regardless of the details, being an effective contributor means that you're adding _adding value_ to a project. 37 | 38 | Here are just a few of the advantages of adding value to a project: 39 | 40 | - you gain the appreciation and respect of the project's maintainers and community 41 | - you gain valuable experience 42 | - you get noticed by job recruiters 43 | - you become more attrative to potential employers. 44 | 45 | ## Getting familiarized with a project 46 | 47 | Before you attempt to contribute to a project, take a moment to get familiarized with it. In most cases you can learn all you need to know within a couple of minutes. 48 | 49 | ### Required 50 | 51 | The following items are a pre-requisite for contributing to any project. Avoid creating issues or doing pull requests until you've done all of these things: 52 | 53 | - **Review the readme**: Oftentimes a project readme has links to documentation, advice on creating issues or bug reports, and so on. 54 | - **Read contributing guidelines**: look for a `CONTRIBUTING.md` file and, if one exists, read it in its entirety before creating issues or doing a pull request. Typically this is in the root of the project, but it might be in `.github/CONTRIBUTING.md`. 55 | - **Search issues**: Before creating bug reports, feature requests, or submitting issues of any kind, you should always search for existing issues (closed or open) that address the same thing. 56 | 57 | ### Recommended 58 | 59 | - **Review unit tests** - one of the best ways to get familiarized with a project is through its unit tests. Of course, this depends on the type of project, complexity, test coverage, and so on. But when applicable, test are often a good source of insight. 60 | - **Get familiarized with the code** - If the codebase is small, and you're familiar with the language, take a moment to review the code to see if you find anything that can be improved. If the codebase is large, you might be able to provide domain expertise or fixes for specific areas. 61 | - **Ask questions** - Depending the project type and size, it might be good to start by searching google to find anwers to your questions. Then, check to see if the project uses [gitter](https://gitter.im) or has a [slack](https://slack.com) channel, or something similar. Also visit [stackoverflow](https://stackoverflow.com) and do a search to see if others have already asked the same question. As a last resort, create an issue on the project's GitHub repository. 62 | 63 | 64 | ## Details of Highly Effective Bug Reports 65 | 66 | ### Rationale 67 | 68 | The easier you make it for a maintainter or members of the community to react, the more likely it is for them to react quickly. 69 | 70 | Like you, maintainers have to make decisions about where to spend their time. Not only within a given project, but oftentimes across multiple projects. If you're experiencing a bug and you want to make a report, bug reports that are clearly described and organized are much more likely to get addressed by the maintainers or member of the community. 71 | 72 | Providing these details up front will make everyone happy. If you don't provide these details, maintainers will have to ask you for them, which can be annoying for experienced maintainers who have had to ask for these crucial details many times. 73 | 74 | ### The details 75 | 76 | Always include the following essential details in every bug report: 77 | 78 | 1. **version**: what version of `es6-template` were you using when you experienced the bug? 79 | 2. **description**: clear description of the bug, and minimum steps to reproduce it. 80 | 3. **error messages**: paste any error messages into the issue or a [github gist](https://gist.github.com/), use [gfm code blocks][gfm]. 81 | 4. **code**: paste any code necessary for reproducing the bug and use [gfm code blocks][gfm] to wrap the code. 82 | 5. **title**: use a clear and descriptive title. 83 | 84 | See GitHub's guide to [Creating and highlighting code blocks][gfm] for more details. 85 | 86 | ## Submitting a pull requests 87 | 88 | **Working on your first Pull Request?** 89 | 90 | You can learn how from this *free* video series ["How to Contribute to an Open Source Project on GitHub"][howto-oss-github] 91 | 92 | **Details** 93 | 94 | - Non-trivial changes are often best discussed in an issue first, to prevent you from doing unnecessary work. 95 | - For ambitious tasks, you should try to get your work in front of the community for feedback as soon as possible. Open a pull request as soon as you have done the minimum needed to demonstrate your idea. At this early stage, don't worry about making things perfect, or 100% complete. Add a [WIP] prefix to the title, and describe what you still need to do. This lets reviewers know not to nit-pick small details or point out improvements you already know you need to make. 96 | - New features should be accompanied with tests and documentation. 97 | - Don't include unrelated changes. 98 | - Lint and test immediately after you fork by running `$ npm test`. 99 | - Lint and test before submitting the pull request by running `$ npm test`. 100 | - Make the pull request from a [topic branch](https://github.com/dchelimsky/rspec/wiki/Topic-Branches), not master. 101 | - Use a clear and descriptive title for the pull request and commits. 102 | - Write a convincing description of why we should land your pull request. It's your job to convince us. Answer "why" it's needed and provide use-cases. 103 | - You might be asked to do changes to your pull request. There's never a need to open another pull request. [Just update the existing one.][amending] 104 | 105 | ## Other ways to contribute 106 | 107 | ### Show your support 108 | 109 | Sometimes we find a project we like but just don't have time to contribute. That's okay, there are other ways to show support: 110 | 111 | - Star the project 112 | - Tweet about it 113 | - Tell your friends 114 | 115 | ### Show your appreciation 116 | 117 | Maintainers are people too. You can make someone's day by letting them know you appreciate their work. If you use a library in one of your own projects, let the author know you care: 118 | 119 | - Add a link to the project on your project's readme 120 | - Say "thanks" on twitter 121 | 122 | ## Attribution 123 | 124 | This document is adapted from a few Contributing Guides. It is more general and can apply in most cases. Everyone is free to re-use it or re-adapt it. 125 | 126 | ### Good to read 127 | 128 | - [Awesome Contributing][awesomelist] 129 | - [Idiomatic Contributing][idiomatic] 130 | - [AVA's Contributing Guide][avajs] 131 | - [Amending a commit Guide][amending] 132 | - [Creating and highlighting code blocks][gfm] 133 | - [Contributing to Open Source (GitHub)][os-on-github] 134 | - [How to contribute to Open Source Project (Egghead.io videos)][howto-oss-github] 135 | 136 | ### Authors 137 | 138 | **Charlike Mike Reagent** 139 | 140 | * [github/tunnckoCore](https://github.com/tunnckoCore) 141 | * [twitter/tunnckoCore](http://twitter.com/tunnckoCore) 142 | 143 | ## License 144 | 145 | Released under [Creative Commons](https://creativecommons.org/licenses/by/3.0/). 146 | Copyright © 2016, [Charlike Mike Reagent](http://www.tunnckocore.tk). 147 | 148 | [gfm]: https://help.github.com/articles/creating-and-highlighting-code-blocks/ 149 | [avajs]: https://github.com/avajs/ava/blob/master/contributing.md 150 | [idiomatic]: https://github.com/jonschlinkert/idiomatic-contributing 151 | [awesomelist]: https://github.com/jonschlinkert/awesome-contributing 152 | [amending]: https://github.com/RichardLitt/docs/blob/master/amending-a-commit-guide.md 153 | [os-on-github]: https://guides.github.com/activities/contributing-to-open-source/ 154 | [howto-oss-github]: http://j.mp/how-to-contrib-on-github -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-2016 Charlike Mike Reagent 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [es6-template][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url] [![npm downloads][downloads-img]][downloads-url] 2 | 3 | > Small, sync and async es6 template engine, built on top of [gana][] and ES6/ES2015 Template Strings, working on `node@0.10` too! 4 | 5 | [![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] 6 | 7 | ## Background 8 | 9 | Behind 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**). 10 | 11 | Works well on browsers and even in `node@0.10`. [Read more](https://github.com/tunnckocore/gana#background) on `gana` readme. 12 | 13 | ## Install 14 | ``` 15 | npm i es6-template --save 16 | ``` 17 | 18 | ## Usage 19 | > For more use-cases see the [tests](./test.js) 20 | 21 | ```js 22 | const es6template = require('es6-template') 23 | ``` 24 | 25 | ### [es6template](index.js#L57) 26 | > 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. 27 | 28 | **Params** 29 | 30 | * `