Skip to content

rubeniskov/templatefy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ƬΞMPLATEFY

Build Status Version Coverage Status GPA Status Commits Issues Open Issue Resolution

Node Downloads Slack Status Twitter Paypal Beerpay License

Templatefy is a html template manager with js injection, angular supported.

NPM NPM GRID

ƬΞ - Table of contents

ƬΞ - Installation

Install with npm install templatefy --save.

ƬΞ - CLI (Command line interface)

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.

Options

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

  █████████╗███████╗███╗   ███╗██████╗ ██╗      █████╗ ████████╗███████╗███████╗██╗   ██╗
 ███╔═██╔══╝╚══════╝████╗ ████║██╔══██╗██║     ██╔══██╗╚══██╔══╝██╔════╝██╔════╝╚██╗ ██╔╝
 ╚══╝ ██║   █████╗  ██╔████╔██║██████╔╝██║     ███████║   ██║   █████╗  █████╗   ╚████╔╝  
      ██║   ╚════╝  ██║╚██╔╝██║██╔═══╝ ██║     ██╔══██║   ██║   ██╔══╝  ██╔══╝    ╚██╔╝   
      ██║   ███████╗██║ ╚═╝ ██║██║     ███████╗██║  ██║   ██║   ███████╗██║        ██║    
      ╚═╝   ╚══════╝╚═╝     ╚═╝╚═╝     ╚══════╝╚═╝  ╚═╝   ╚═╝   ╚══════╝╚═╝        ╚═╝  

Go top

Usage

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!.

Go top

ƬΞ - API (Application Programming Interface)

Options

scope

Type: Boolean Default: false

Enable function clousure for prevent variable collisions.

exports

Type: Boolean Default: false

Enable commonjs module.exports.

global

Type: String Default: null

Global variable expose global:property.

var

Type: String Default: null

Local variable name.

angular

Type: Boolean Object Default: false

Enable angular templateCache injection.

angular.shim

Type: String Default: angular

Angular variable name or factory.

angular.module.name

Type: String Default: templatefy

Angular templatefy module name.

angular.module.var

Type: String Default: templatefy

Angular templatefy module variable name.

angular.module.name

Type: String Default: templatefy

Angular templatefy module name.

angular.module.deps

Type: Array String Default: null

Angular templatefy module dependencies.

angular.module.run.args

Type: Array String Default: null

Angular templatefy module run dependencies.

angular.template

Type: Array String Default: null

Angular templatefy template name.

Go top

Usage

To use, add the require node module:

    const Templatefy = require('templatefy');

    Templatefy.parse('path/of/input-file.html', 'path/of/ouput-file.js');

Input (path/of/input-file.html)

    <h1><h2><h3>

Output (path/of/ouput-file.js)

    '<h1><h2><h3></h3></h2></h1>'

Go top

ƬΞ - Live examples

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);
    });

Try this snippet!! Go top

ƬΞ - Documentation (WIP)

I'm working hard to develop the documentation a soon as possible, sorry for the inconvenience.

Go top

ƬΞ - Contributing (WIP)

WIP

Go top

Community

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.com server, in the ##templatefy channel.
  • Developers should use the keyword templatefy on packages which modify or add to the functionality of Templatefy when distributing through npm or similar delivery mechanisms for maximum discoverability.

Go top

ƬΞ - Creators

Rubén López Gómez me@rubeniskov.com

Go top

ƬΞ - Copyright and license

Code copyright 2016 Rubeniskov released under the MIT license.

Go top

About

A html template manager with js injection, angular supported

Resources

License

Stars

Watchers

Forks

Packages

No packages published