1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
.\" generated with Ronn/v0.5
.\" http://github.com/rtomayko/ronn/
.
.TH "MUSTACHE" "1" "May 2010" "DEFUNKT" "Mustache Manual"
.
.SH "NAME"
\fBmustache\fR \-\- Mustache processor
.
.SH "SYNOPSIS"
.
.nf
mustache <YAML> <FILE>
mustache \-\-compile <FILE>
mustache \-\-tokens <FILE>
.
.fi
.
.SH "DESCRIPTION"
Mustache is a logic\-less templating system for HTML, config files,
anything.
.
.P
The \fBmustache\fR command processes a Mustache template preceded by YAML
frontmatter from standard input and prints one or more documents to
standard output.
.
.P
YAML frontmatter beings with \fB\-\-\-\fR on a single line, followed by YAML,
ending with another \fB\-\-\-\fR on a single line, e.g.
.
.IP "" 4
.
.nf
\-\-\-
names: [ {name: chris}, {name: mark}, {name: scott} ]
\-\-\-
.
.fi
.
.IP "" 0
.
.P
If you are unfamiliar with YAML, it is a superset of JSON. Valid JSON
should work fine.
.
.P
After the frontmatter should come any valid Mustache template. See
mustache(5) for an overview of Mustache templates.
.
.P
For example:
.
.IP "" 4
.
.nf
{{#names}}
Hi {{name}}!
{{/names}}
.
.fi
.
.IP "" 0
.
.P
Now let's combine them.
.
.IP "" 4
.
.nf
$ cat data.yml
\-\-\-
names: [ {name: chris}, {name: mark}, {name: scott} ]
\-\-\-
$ cat template.mustache
{{#names}}
Hi {{name}}!
{{/names}}
$ cat data.yml template.mustache | mustache
Hi chris!
Hi mark!
Hi scott!
.
.fi
.
.IP "" 0
.
.P
If you provide multiple YAML documents (as delimited by \fB\-\-\-\fR), your
template will be rendered multiple times. Like a mail merge.
.
.P
For example:
.
.IP "" 4
.
.nf
$ cat data.yml
\-\-\-
name: chris
\-\-\-
name: mark
\-\-\-
name: scott
\-\-\-
$ cat template.mustache
Hi {{name}}!
$ cat data.yml template.mustache | mustache
Hi chris!
Hi mark!
Hi scott!
.
.fi
.
.IP "" 0
.
.SH "OPTIONS"
By default \fBmustache\fR will try to render a Mustache template using the
YAML frontmatter you provide. It can do a few other things, however.
.
.TP
\fB\-c\fR, \fB\-\-compile\fR
Print the compiled Ruby version of a given template. This is the
code that is actually used when rendering a template into a
string. Useful for debugging but only if you are familiar with
Mustache's internals.
.
.TP
\fB\-t\fR, \fB\-\-tokens\fR
Print the tokenized form of a given Mustache template. This can be
used to understand how Mustache parses a template. The tokens are
handed to a generator which compiles them into a Ruby
string. Syntax errors and confused tags, therefor, can probably be
identified by examining the tokens produced.
.
.SH "INSTALLATION"
If you have RubyGems installed:
.
.IP "" 4
.
.nf
gem install mustache
.
.fi
.
.IP "" 0
.
.SH "EXAMPLES"
.
.nf
$ mustache data.yml template.mustache
$ cat data.yml | mustache \- template.mustache
$ mustache \-c template.mustache
$ cat <<data | ruby mustache \- template.mustache
\-\-\-
name: Bob
age: 30
\-\-\-
data
.
.fi
.
.SH "COPYRIGHT"
Mustache is Copyright (C) 2009 Chris Wanstrath
.
.P
Original CTemplate by Google
.
.SH "SEE ALSO"
mustache(5), mustache(7), gem(1), \fIhttp://mustache.github.com/\fR
|