Skip to content

Commit 8794214

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #163 from e2tha-e/list-item-verbose-partials
allowing verbose partials for list items
2 parents c24c761 + dc5333b commit 8794214

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

builder/list_item_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
for(var j = 0; j < foundPartials.length; j++){
6969

7070
//get the partial
71-
var partialName = foundPartials[j].match(/([a-z-]+)/ig)[0];
71+
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
7272
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
7373

7474
//replace its reference within the block with the extended template

test/list_item_hunter_tests.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,73 @@
100100
test.done();
101101
},
102102

103+
'process_list_item_partials finds verbose partials and outputs repeated renders' : function(test){
104+
var pattern1 = {
105+
"template": "{{#listItems.one}}{{> 00-test/00-foo }}{{/listItems.one}}",
106+
"extendedTemplate" : "{{#listItems.one}}{{> 00-test/00-foo }}{{/listItems.one}}",
107+
"key": "test-patternName1",
108+
"jsonFileData" : {}
109+
};
110+
111+
var pattern2 = {
112+
"template": "{{#listItems.two}}{{> 00-test/01-bar.mustache }}{{/listItems.two}}",
113+
"extendedTemplate" : "{{#listItems.two}}{{> 00-test/01-bar.mustache }}{{/listItems.two}}",
114+
"key": "test-patternName2",
115+
"jsonFileData" : {}
116+
};
117+
118+
var patternlab = {
119+
"listitems": {
120+
"1": [
121+
{
122+
"title": "Foo"
123+
}
124+
],
125+
"2": [
126+
{
127+
"title": "Foo"
128+
},
129+
{
130+
"title": "Bar"
131+
}
132+
]
133+
},
134+
"data": {
135+
"link": {},
136+
"partials": []
137+
},
138+
"config": {"debug": false},
139+
"patterns": [
140+
{
141+
"template": "{{ title }}",
142+
"extendedTemplate" : "{{ title }}",
143+
"subdir": "00-test",
144+
"fileName": "00-foo",
145+
"jsonFileData" : {}
146+
},
147+
{
148+
"template": "{{ title }}",
149+
"extendedTemplate" : "{{ title }}",
150+
"subdir": "00-test",
151+
"fileName": "01-bar",
152+
"jsonFileData" : {}
153+
}
154+
]
155+
};
156+
157+
var list_item_hunter = new lih();
158+
159+
//act
160+
list_item_hunter.process_list_item_partials(pattern1, patternlab);
161+
list_item_hunter.process_list_item_partials(pattern2, patternlab);
162+
163+
//assert
164+
test.equals(pattern1.extendedTemplate, "Foo" );
165+
test.equals(pattern2.extendedTemplate, "FooBar" );
166+
167+
test.done();
168+
},
169+
103170
'process_list_item_partials overwrites listItem property if that property is in local .listitem.json' : function(test){
104171
//arrange
105172
//setup current pattern from what we would have during execution

0 commit comments

Comments
 (0)