Procházet zdrojové kódy

fixed distinction between false-y values (which *should* fill tags) and actually undefined values

parser-rewrite
nathan@stravinsky.local před 16 roky
rodič
revize
90f61c8204
1 změnil soubory, kde provedl 3 přidání a 4 odebrání
  1. +3
    -4
      mustache.js

+ 3
- 4
mustache.js Zobrazit soubor

@@ -170,12 +170,11 @@ var Mustache = function() {
} 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) {
var rawValue = this.lookupValue(item.tag, context); var rawValue = this.lookupValue(item.tag, context);
if (rawValue) {
if (rawValue != null) {
var value = rawValue.toString(); var value = rawValue.toString();
this.send((item.noEscape) ? value : this.escapeHTML(value)); this.send((item.noEscape) ? value : this.escapeHTML(value));
} }
@@ -193,7 +192,7 @@ var Mustache = function() {
value = value.apply(context); value = value.apply(context);
} }
// silently ignore unkown variables // silently ignore unkown variables
if (!value) {
if (value == null) {
value = ""; value = "";
} }
return value; return value;
@@ -219,7 +218,7 @@ var Mustache = function() {
valueIterator: function(name, context) { valueIterator: function(name, context) {
var value = this.lookupValue(name, context); var value = this.lookupValue(name, context);
var me = this; var me = this;
if (!value) {
if (value == null) {
return function(){}; return function(){};
} else if (value instanceof Function && value.iterator) { } else if (value instanceof Function && value.iterator) {
return value; return value;


Načítá se…
Zrušit
Uložit