Skip to content

Commit 10fac0b

Browse files
committed
make it work with the new full-oPattern passing regime
1 parent edb74ae commit 10fac0b

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

lib/engine_mustache.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,19 @@ var engine_mustache = {
3636
findPartialsWithStyleModifiersRE: utilMustache.partialsWithStyleModifiersRE,
3737
findPartialsWithPatternParametersRE: utilMustache.partialsWithPatternParametersRE,
3838
findListItemsRE: utilMustache.listItemsRE,
39-
findPartialKeyRE: utilMustache.partialKeyRE,
39+
findPartialRE: utilMustache.partialRE,
4040

4141
// render it
42-
renderPattern: function renderPattern(template, data, partials) {
43-
if (partials) {
44-
return Mustache.render(template, data, partials);
42+
renderPattern: function renderPattern(pattern, data, partials) {
43+
try {
44+
if (partials) {
45+
return Mustache.render(pattern.extendedTemplate, data, partials);
46+
}
47+
return Mustache.render(pattern.extendedTemplate, data);
48+
} catch (e) {
49+
debugger;
50+
console.log("e = ", e);
4551
}
46-
return Mustache.render(template, data);
4752
},
4853

4954
/**
@@ -88,26 +93,26 @@ var engine_mustache = {
8893

8994
// given a pattern, and a partial string, tease out the "pattern key" and
9095
// return it.
91-
findPartialKey_new: function (partialString) {
92-
var partialKey = partialString.replace(this.findPartialKeyRE, '$1');
93-
return partialKey;
96+
findPartial_new: function (partialString) {
97+
var partial = partialString.replace(this.findPartialRE, '$1');
98+
return partial;
9499
},
95100

96101
// GTP: the old implementation works better. We might not need
97-
// this.findPartialKeyRE anymore if it works in all cases!
98-
findPartialKey: function (partialString) {
102+
// this.findPartialRE anymore if it works in all cases!
103+
findPartial: function (partialString) {
99104
//strip out the template cruft
100-
var foundPatternKey = partialString.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
105+
var foundPatternPartial = partialString.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
101106

102107
// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
103-
if (foundPatternKey.indexOf('(') > 0) {
104-
foundPatternKey = foundPatternKey.substring(0, foundPatternKey.indexOf('('));
108+
if (foundPatternPartial.indexOf('(') > 0) {
109+
foundPatternPartial = foundPatternPartial.substring(0, foundPatternPartial.indexOf('('));
105110
}
106111

107112
//remove any potential stylemodifiers.
108-
foundPatternKey = foundPatternKey.split(':')[0];
113+
foundPatternPartial = foundPatternPartial.split(':')[0];
109114

110-
return foundPatternKey;
115+
return foundPatternPartial;
111116
}
112117
};
113118

0 commit comments

Comments
 (0)