Bladeren bron

switched to @janl's way of handling partials to pass more tests

parser-rewrite
nathan@stravinsky.local 16 jaren geleden
bovenliggende
commit
54c62e8a58
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. +6
    -4
      mustache.js

+ 6
- 4
mustache.js Bestand weergeven

@@ -159,16 +159,18 @@ var Mustache = function() {
if (!subTemplate) { if (!subTemplate) {
throw new Error("Unknown partial '" + item.tag + "'"); throw new Error("Unknown partial '" + item.tag + "'");
} }
this.render(subTemplate, context, partials);
// TODO: below matches @janl's mustache, but not mustache(5)
/*
// this is the mustache(5) way
// this.render(subTemplate, context, partials);
// this is @janl's way
var subContext = context[item.tag]; var subContext = context[item.tag];
if (typeof(subContext) == "object") { if (typeof(subContext) == "object") {
this.render(subTemplate, subContext, partials); this.render(subTemplate, subContext, partials);
} else { } else {
this.send(subTemplate); this.send(subTemplate);
} }
*/
} else if (item.operator && !item.noEscape) { } else if (item.operator && !item.noEscape) {
// ignore other operators // ignore other operators
} else if (item.tag) { } else if (item.tag) {


Laden…
Annuleren
Opslaan