@@ -150,6 +150,19 @@ let manpage = Cmdliner.[
150150 (leftmost $(b,-I) option) has precedence, and the current working directory has precedence
151151 over include directories." ;
152152
153+ `S " TEMPLATE INHERITANCE / PARTIALS WITH PARAMETERS" ;
154+
155+ `P " $(i,ocaml-mustache) supports a common extension to the original Mustache specification,
156+ called 'template inheritance' or 'parent partials', or here 'partials with parameters'.
157+ In addition to usual partials '{{>foo}}', which include a partial template, one can use
158+ the syntax '{{<bar}} {{\\ $param1}}...{{/param1}} {{\\ $param2}}...{{/param2}} {{/bar}}' to
159+ pass parameters to the included partial template. Inside this included template, parameters
160+ are used as '{{\\ $param}}...{{/param}}', with the inner content being used by default
161+ if this parameter was not specified by the caller." ;
162+
163+ `P " This is typically used to define page layouts that are wrapped 'around' the current template.
164+ See our EXAMPLES." ;
165+
153166 `S Manpage. s_examples;
154167 `Pre {|
155168# # Simple usage.
@@ -172,7 +185,7 @@ Mustache is:
172185- fun
173186
174187
175- ## Using a partial to include a subpage ; see $(b ,PARTIALS).
188+ ## Including a subpage ; see $(b ,PARTIALS).
176189
177190\$ cat page .mustache
178191<html >
@@ -189,6 +202,47 @@ Mustache is:
189202 - simple
190203 - fun
191204 </body >
205+ </html >
206+
207+
208+ ## Including a layount around a page ; see $(b ,PARTIALS WITH PARAMETERS).
209+
210+ \$ cat new -post .json
211+ {
212+ "title": "New Post",
213+ "authors": "Foo and Bar",
214+ "date": "today",
215+ "content": "Shiny new content."
216+ }
217+
218+ \$ cat post .mustache
219+ {{<post-layout} }
220+ {{\$page-title} }Post: {{title} }{{/page-title} }
221+ {{\$content} }
222+ <h1 >{{title} }</h1 >
223+ <p >{{content} }</p >
224+ {{/content} }
225+ {{/post-layout} }
226+
227+ \$ cat post -layout .mustache
228+ <html >
229+ <head >
230+ <title >{{\$page-title} }Default Title{{/page-title} }</title >
231+ </head >
232+ <body >
233+ {{\$content} }{{/content} }
234+ </body >
235+ </html >
236+
237+ \$ $(tname ) new -post .json post .mustache
238+ <html >
239+ <head >
240+ <title >Post: New Post</title >
241+ </head >
242+ <body >
243+ <h1 >New Post</h1 >
244+ <p >Shiny new content .</p >
245+ </body >
192246</html >|};
193247
194248 `S "CONFORMING TO" ;
@@ -200,6 +254,9 @@ Mustache is:
200254 `I ("Mustache specification testsuite" ,
201255 "https://github.com/mustache/spec" );
202256
257+ `I ("Semi-official specification of PARTIALS WITH PARAMETERS" ,
258+ "https://github.com/mustache/spec/pull/75" );
259+
203260 `S "REPORTING BUGS" ;
204261 `P "Report bugs on https://github.com/rgrinberg/ocaml-mustache/issues" ;
205262]
0 commit comments