Skip to content

Commit d1ccd19

Browse files
committed
test the examples from the manpage
1 parent c8da066 commit d1ccd19

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{ "name": "OCaml",
2+
"qualities": [{"name": "simple"}, {"name": "fun"}] }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Hello {{name}}!
2+
Mustache is:
3+
{{#qualities}}
4+
- {{name}}
5+
{{/qualities}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"title": "New Post",
3+
"content": "Shiny new content."
4+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html>
2+
<head>
3+
<title>{{$page-title}}Default Title{{/page-title}}</title>
4+
</head>
5+
<body>
6+
{{$content}}{{/content}}
7+
</body>
8+
</html>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<body>
3+
{{>hello}}
4+
</body>
5+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{<page-layout}}
2+
{{$page-title}}Post: {{title}}{{/page-title}}
3+
{{$content}}
4+
<h1>{{title}}</h1>
5+
<p>{{content}}</p>
6+
{{/content}}
7+
{{/page-layout}}

bin/test/manpage-examples.t/run.t

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
Simple usage:
2+
3+
$ cat data.json
4+
{ "name": "OCaml",
5+
"qualities": [{"name": "simple"}, {"name": "fun"}] }
6+
7+
$ cat hello.mustache
8+
Hello {{name}}!
9+
Mustache is:
10+
{{#qualities}}
11+
- {{name}}
12+
{{/qualities}}
13+
14+
$ mustache data.json hello.mustache
15+
Hello OCaml!
16+
Mustache is:
17+
- simple
18+
- fun
19+
20+
21+
Using a partial to include a subpage:
22+
23+
$ cat page.mustache
24+
<html>
25+
<body>
26+
{{>hello}}
27+
</body>
28+
</html>
29+
30+
$ mustache data.json page.mustache
31+
<html>
32+
<body>
33+
Hello OCaml!
34+
Mustache is:
35+
- simple
36+
- fun
37+
</body>
38+
</html>
39+
40+
41+
Using a partial with parameters to include a layout around a page:
42+
43+
$ cat new-post.json
44+
{
45+
"title": "New Post",
46+
"content": "Shiny new content."
47+
}
48+
49+
$ cat post.mustache
50+
{{<page-layout}}
51+
{{$page-title}}Post: {{title}}{{/page-title}}
52+
{{$content}}
53+
<h1>{{title}}</h1>
54+
<p>{{content}}</p>
55+
{{/content}}
56+
{{/page-layout}}
57+
58+
$ cat page-layout.mustache
59+
<html>
60+
<head>
61+
<title>{{$page-title}}Default Title{{/page-title}}</title>
62+
</head>
63+
<body>
64+
{{$content}}{{/content}}
65+
</body>
66+
</html>
67+
68+
$ mustache new-post.json post.mustache
69+
<html>
70+
<head>
71+
<title>Post: New Post</title>
72+
</head>
73+
<body>
74+
<h1>New Post</h1>
75+
<p>Shiny new content.</p>
76+
</body>
77+
</html>

0 commit comments

Comments
 (0)