Quellcode durchsuchen

Partials compiler should be non-destructive

tags/0.5.0-vsc
unknown vor 16 Jahren
Ursprung
Commit
98cdab2af5
2 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
  1. +8
    -1
      mustache.js
  2. +5
    -1
      test/unit.compiler.js

+ 8
- 1
mustache.js Datei anzeigen

@@ -773,11 +773,18 @@ var Mustache = function() {
}
},
compile: function(template, partials) {
var p = {};
for (var key in partials) {
if (partials.hasOwnProperty(key)) {
p[key] = partials[key];
}
}
var commands = [];
var s = function(command) { commands.push(command); };
var renderer = new Renderer(s, 'compiler');
renderer.render(template, {}, partials);
renderer.render(template, {}, p);

return function(view, send_func) {
var o = send_func ? undefined : [];


+ 5
- 1
test/unit.compiler.js Datei anzeigen

@@ -15,7 +15,7 @@ module('Compiler', {
});

test("Parser", function() {
expect(3);
expect(4);

// matches whitespace_partial.html
equals(
@@ -67,6 +67,10 @@ test("Parser", function() {
equals(e.message, 'Unexpected end of document.');
}
var partials = { 'partial' : '{{key}}' };
Mustache.compile('{{>partial}}', partials );
equals(partials['partial'], '{{key}}', 'Partials compiler must be non-destructive');
});

test("Basic Variables", function() {


Laden…
Abbrechen
Speichern