An open API service indexing awesome lists of open source software.

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

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