mplate
v1.0.0
Published
Render template from command line. Supports multiple engines and is pipeable with your favorites tools!
Downloads
4
Maintainers
Readme
mplate
Render template from command line. Supports multiple engines and is pipeable with your favorites tools!
Supported template engine
- ejs default
- es6
- Handlebars
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!