@@ -86,6 +86,19 @@ let manpage = Cmdliner.[
8686 (leftmost $(b,-I) option) has precedence, and the current working directory has precedence
8787 over include directories." ;
8888
89+ `S " TEMPLATE INHERITANCE / PARTIALS WITH PARAMETERS" ;
90+
91+ `P " $(i,ocaml-mustache) supports a common extension to the original Mustache specification,
92+ called 'template inheritance' or 'parent partials', or here 'partials with parameters'.
93+ In addition to usual partials '{{>foo}}', which include a partial template, one can use
94+ the syntax '{{<bar}} {{\\ $param1}}...{{/param1}} {{\\ $param2}}...{{/param2}} {{/bar}}' to
95+ pass parameters to the included partial template. Inside this included template, parameters
96+ are used as '{{\\ $param}}...{{/param}}', with the inner content being used by default
97+ if this parameter was not specified by the caller." ;
98+
99+ `P " This is typically used to define page layouts that are wrapped 'around' the current template.
100+ See our EXAMPLES." ;
101+
89102 `S Manpage. s_examples;
90103 `Pre {|
91104# # Simple usage.
@@ -108,7 +121,7 @@ Mustache is:
108121- fun
109122
110123
111- ## Using a partial to include a subpage ; see $(b ,PARTIALS).
124+ ## Including a subpage ; see $(b ,PARTIALS).
112125
113126\$ cat page .mustache
114127<html >
@@ -125,6 +138,47 @@ Mustache is:
125138 - simple
126139 - fun
127140 </body >
141+ </html >
142+
143+
144+ ## Including a layount around a page ; see $(b ,PARTIALS WITH PARAMETERS).
145+
146+ \$ cat new -post .json
147+ {
148+ "title": "New Post",
149+ "authors": "Foo and Bar",
150+ "date": "today",
151+ "content": "Shiny new content."
152+ }
153+
154+ \$ cat post .mustache
155+ {{<post-layout} }
156+ {{\$page-title} }Post: {{title} }{{/page-title} }
157+ {{\$content} }
158+ <h1 >{{title} }</h1 >
159+ <p >{{content} }</p >
160+ {{/content} }
161+ {{/post-layout} }
162+
163+ \$ cat post -layout .mustache
164+ <html >
165+ <head >
166+ <title >{{\$page-title} }Default Title{{/page-title} }</title >
167+ </head >
168+ <body >
169+ {{\$content} }{{/content} }
170+ </body >
171+ </html >
172+
173+ \$ $(tname ) new -post .json post .mustache
174+ <html >
175+ <head >
176+ <title >Post: New Post</title >
177+ </head >
178+ <body >
179+ <h1 >New Post</h1 >
180+ <p >Shiny new content .</p >
181+ </body >
128182</html >|};
129183
130184 `S "CONFORMING TO" ;
@@ -136,6 +190,9 @@ Mustache is:
136190 `I ("Mustache specification testsuite" ,
137191 "https://github.com/mustache/spec" );
138192
193+ `I ("Semi-official specification of PARTIALS WITH PARAMETERS" ,
194+ "https://github.com/mustache/spec/pull/75" );
195+
139196 `S "REPORTING BUGS" ;
140197 `P "Report bugs on https://github.com/rgrinberg/ocaml-mustache/issues" ;
141198]
0 commit comments