Debian Codegraph @

man/mustache.1

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