0.2.4 • Published 8 years ago

templatefy v0.2.4

Weekly downloads
2
License
-
Repository
github
Last release
8 years ago

Templatefy

Build Status Coverage Status GPA Status Commits Issues Open Issue Resolution

Version Node Downloads Slack Status 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: /usr/local/bin/node templatefy [options]

Options:
   -i, --input     Input html file or string raw template
   -o, --output    Output compiled JavaScript file template
   -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 HTML minification process; for log options use --minify-<option-name>  [false]
   -V, --log       Enable log output; for minify options use --log-<option-name>  [false]
   -v, --version   Print version and exit

Go top

Usage

This example shows how to pass through stdin a template obtaining the output to the 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 --output it be will print the result in the promt 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

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.0

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.8

8 years ago

0.0.7

8 years ago

0.0.6

8 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.1

8 years ago