mplate
v1.0.0
Published
Render template from command line. Supports multiple engines and is pipeable with your favorites tools!
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 mplateUsage
Render template to file
Template welcome.ejs
Welcome <%= username %>!Run:
mplate --context "{\"username\": \"admin\"}" -f welcome.ejs -o out.txtRender 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/homeLoad context from file
Context file context.yaml
user:
name: adminRun:
echo "Welcome <%= user.name %>!" | mplate --context-file context.yaml --context-format yaml
Welcome admin!