Skip to content

Commit b582bb7

Browse files
committed
Add partials examples. Not working yet, but work in progress.
1 parent bd17494 commit b582bb7

File tree

5 files changed

+41
-3
lines changed

5 files changed

+41
-3
lines changed

examples/forecast.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{dayOfWeek}}:
2+
Conditions: {{conditions}}
3+
High: {{highTemp}} Low: {{lowTemp}}

examples/hash_lists.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ employees:
1919
position: Sales Associate
2020
salary: 38,000
2121
vacationDaysLeft: 4
22-
...
23-
22+
---

examples/partials.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{#forecasts}}
2+
{{> forecast}}
3+
4+
{{/forecasts}}

examples/partials.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
forecasts:
3+
- dayOfWeek: Monday
4+
conditions: Cloudy
5+
highTemp: 65
6+
lowTemp: 50
7+
8+
- dayOfWeek: Tuesday
9+
conditions: Sunny
10+
highTemp: 78
11+
lowTemp: 58
12+
13+
- dayOfWeek: Wednesday
14+
conditions: Rain
15+
highTemp: 58
16+
lowTemp: 48
17+
---

mustang/TagParser.ooc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ SectionParser: class extends TagParser {
6464
}
6565
}
6666

67+
/**
68+
Partial tag parser.
69+
70+
Syntax: {{>user}}
71+
*/
72+
PartialParser: class extends TagParser {
73+
matches: func(tag: String) -> Bool { tag first() == '>' }
74+
75+
parse: func(tag: String) -> TNode {
76+
"Parsed parital tag!" println()
77+
null
78+
}
79+
}
80+
6781
loadBuiltinParsers: func(parsers: List<TagParser>) {
68-
parsers add(VariableParser new()) .add(CommentParser new()) .add(SectionParser new())
82+
parsers add(VariableParser new()). add(CommentParser new()).
83+
add(SectionParser new()). add(PartialParser new())
6984
}

0 commit comments

Comments
 (0)