Templatefy is a html template manager with js injection, angular supported.
- Motivation
- Installation
- CLI Usage
- API Usage
- Live Examples
- Documentation
- Contributing
- Community
- Creators
- Copyright and license
Install with npm install templatefy --save.
You can use Templatefy as command line tool, installing as global library with npm i -g templatefy and execute with the command templatefy.
To show options type: templatefy --help or with flag -h.
Usage: templatefy [options]
Options:
-i, --input Input html file or string template
-o, --output Output compiled JavaScript file templated
-s, --scope Enable scope function to prevent collition declarations [false]
-e, --exports Exports the template using commonjs module exports [false]
-r, --var Store the template into a variable
-g, --global Store the template into a global property <global:property>
-a, --angular Enable Angular templateCache injection; for angular options use --angular-<option-name> [false]
-l, --linter Enable Linter validation; for linter options use --linter-<option-name> [false]
-m, --minify Enable log ouput; for log options use --minify-<option-name> [false]
-V, --log Enable log trace; for log options use --log-<option-name> [false]
-v, --version Print version and exit
█████████╗███████╗███╗ ███╗██████╗ ██╗ █████╗ ████████╗███████╗███████╗██╗ ██╗
███╔═██╔══╝╚══════╝████╗ ████║██╔══██╗██║ ██╔══██╗╚══██╔══╝██╔════╝██╔════╝╚██╗ ██╔╝
╚══╝ ██║ █████╗ ██╔████╔██║██████╔╝██║ ███████║ ██║ █████╗ █████╗ ╚████╔╝
██║ ╚════╝ ██║╚██╔╝██║██╔═══╝ ██║ ██╔══██║ ██║ ██╔══╝ ██╔══╝ ╚██╔╝
██║ ███████╗██║ ╚═╝ ██║██║ ███████╗██║ ██║ ██║ ███████╗██║ ██║
╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
This example shows, how to pass the template through stdin and print the output into stdout:
echo '<h1>Foo</h1>' | templatefy --var=example
# ouput
# var example = '<h1>Foo</h1>';As you can see, it's possible use any string passed into the templatefy stdin, another example using the command cat:
cat index.html | templatefy --exports
# ouput
# module.exports = '<h1>Foo</h1>';If want parse a html file using the command arguments, you can define the file path using --input and --ouput to define the output result
By default if you don't define the --output it will be printed by stdout.
echo '<h1>Foo</h1>' > template.html
cat template.html | templatefy --exports
# or
templatefy --input=./template.html --exports
# or
templatefy --input="<h1>Foo</h1>" --exports
# ouput
# module.exports = '<h1>Foo</h1>';
cat template.html | templatefy --exports --ouput=./ouput.js
# contents of ouput.js
# module.exports = '<h1>Foo</h1>';Note: You can copy any pice of code from above and paste in your terminal. Try it!.
Type: Boolean
Default: false
Enable function clousure for prevent variable collisions.
Type: Boolean
Default: false
Enable commonjs module.exports.
Type: String
Default: null
Global variable expose global:property.
Type: String
Default: null
Local variable name.
Type: Boolean Object
Default: false
Enable angular templateCache injection.
Type: String
Default: angular
Angular variable name or factory.
Type: String
Default: templatefy
Angular templatefy module name.
Type: String
Default: templatefy
Angular templatefy module variable name.
Type: String
Default: templatefy
Angular templatefy module name.
Type: Array String
Default: null
Angular templatefy module dependencies.
Type: Array String
Default: null
Angular templatefy module run dependencies.
Type: Array String
Default: null
Angular templatefy template name.
To use, add the require node module:
const Templatefy = require('templatefy');
Templatefy.parse('path/of/input-file.html', 'path/of/ouput-file.js'); <h1><h2><h3> '<h1><h2><h3></h3></h2></h1>'Thanks to tonicdev.com you can test the bellow examples.
const Templatefy = require("templatefy")
Templatefy.parse({
angular: true
},'<h1>{{Title}}<h2>{{Subtitle}}', function(err, data){
console.log(data);
});I'm working hard to develop the documentation a soon as possible, sorry for the inconvenience.
Get updates on Templatefy's development and chat with the project maintainers and community members.
- Follow me on @rubeniskov on Twitter to get updates.
- Read and subscribe to The Official Templatefy Page (WIP).
- Join the official Slack room.
- Chat with fellow templatefiers in IRC. On the
rubeniskov.irc.slack.comserver, in the##templatefychannel. - Developers should use the keyword
templatefyon packages which modify or add to the functionality of Templatefy when distributing through npm or similar delivery mechanisms for maximum discoverability.
Rubén López Gómez [email protected]
- https://twitter.com/rubeniskov
- https://github.com/rubeniskov
- http://rubeniskov.com
Code copyright 2016 Rubeniskov released under the MIT license.

