1.0.0 • Published 5 years ago

mplate v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

mplate

Render template from command line. Supports multiple engines and is pipeable with your favorites tools!

Supported template engine

Installation

npm install -g mplate

Usage

Render template to file

Template welcome.ejs

Welcome <%= username %>!

Run:

mplate --context "{\"username\": \"admin\"}" -f welcome.ejs -o out.txt

Render template from stream

Run:

echo "Welcome <%= username %>!" | mplate --context "{\"username\": \"admin\"}"
Welcome admin!

Run:

curl -s https://example.com/template/location.ejs | mplate --context "{\"username\": \"admin\"}"
Welcome admin!

Use environment variables

Run:

echo "User home:<%= USER_HOME %>" | mplate --use-env
User home: ~/user/home

Load context from file

Context file context.yaml

user:
    name: admin

Run:

echo "Welcome <%= user.name %>!" | mplate --context-file context.yaml --context-format yaml
Welcome admin!