https://github.com/jwerle/mush
Mustache templates for bash
https://github.com/jwerle/mush
Last synced: 11 months ago
JSON representation
Mustache templates for bash
- Host: GitHub
- URL: https://github.com/jwerle/mush
- Owner: jwerle
- License: mit
- Created: 2013-12-17T15:21:58.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-02-17T18:17:41.000Z (over 3 years ago)
- Last Synced: 2025-04-08T12:21:30.786Z (about 1 year ago)
- Language: Shell
- Size: 32.2 KB
- Stars: 146
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
mush
====
Mustache templates for bash
## install
With [bpkg](https://github.com/bpkg/bpkg):
```sh
$ bpkg install -g jwerle/mush
```
From source:
```sh
$ make install
```
## usage
Suppose you have a template file:
***./template.ms***
```
VAR={{VAR}}
```
You can compile it like such:
```sh
$ cat ./template.ms | VAR=VALUE mush
VAR=123
```
You can utilize stdin in the same way with `echo`
```sh
echo "Today's date is {{DATE}}" | DATE=`date +%D` mush
Today's date is 12/17/13
```
Variables are passed to the view environment variable
definition. Due to the way variables are scoped to the
templates. All environment variables are available to the
template. This includes variables like `$HOME` and `$USER`
Compile a HTML file with partial:
***index.html.ms*** (layout)
```html
{{title}}
{{content}}
```
***page.html.ms*** (partial)
```html
This is the {{name}} page
```
```sh
$ cat index.html.ms | \
title="Awesome Web Site" \
main_css="/css/main.css" \
main_js="/js/main.js" \
content="`cat page.html.ms | name=home mush`" \
mush
```
This will yield:
```html
foo
This is the home page
```
## api
```
usage: mush [-ehV] [-f ] [-o ]
examples:
$ cat file.ms | FOO=BAR mush
$ VALUE=123 mush -f file.ms -o file
$ echo "Today's date is {{DATE}}" | DATE=`date +%D` mush
$ cat ./template.ms | VAR=VALUE mush
options:
-f, --file file to parse
-o, --out output file
-e, --escape escapes html html entities
-h, --help display this message
-V, --version output version
```
## license
MIT