Bläddra i källkod

Bugfix for number rendered as [object Object]

+ minor fix for better error message when running specific render test

Fixes #415
tags/v1.2.0
Phillip Johnsen 11 år sedan
förälder
incheckning
32935dc09b
6 ändrade filer med 25 tillägg och 2 borttagningar
  1. +1
    -0
      .gitignore
  2. +1
    -1
      mustache.js
  3. +8
    -0
      test/_files/implicit_iterator.js
  4. +7
    -0
      test/_files/implicit_iterator.mustache
  5. +3
    -0
      test/_files/implicit_iterator.txt
  6. +5
    -1
      test/render-test.js

+ 1
- 0
.gitignore Visa fil

@@ -5,3 +5,4 @@ dojox
yui3
qooxdoo.mustache.js

npm-debug.log

+ 1
- 1
mustache.js Visa fil

@@ -481,7 +481,7 @@
for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
}
} else if (typeof value === 'object' || typeof value === 'string') {
} else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
} else if (isFunction(value)) {
if (typeof originalTemplate !== 'string')


+ 8
- 0
test/_files/implicit_iterator.js Visa fil

@@ -0,0 +1,8 @@
({
data: {
author: {
twitter_id: 819606,
name: 'janl'
}
}
})

+ 7
- 0
test/_files/implicit_iterator.mustache Visa fil

@@ -0,0 +1,7 @@
{{# data.author.twitter_id }}
<meta name="twitter:site:id" content="{{.}}">
{{/ data.author.twitter_id }}

{{# data.author.name }}
<meta name="twitter:site" content="{{.}}">
{{/ data.author.name }}

+ 3
- 0
test/_files/implicit_iterator.txt Visa fil

@@ -0,0 +1,3 @@
<meta name="twitter:site:id" content="819606">

<meta name="twitter:site" content="janl">

+ 5
- 1
test/render-test.js Visa fil

@@ -5,7 +5,11 @@ var path = require('path');
var _files = path.join(__dirname, '_files');

function getContents(testName, ext) {
return fs.readFileSync(path.join(_files, testName + '.' + ext), 'utf8');
try {
return fs.readFileSync(path.join(_files, testName + '.' + ext), 'utf8');
} catch (ex) {
return null;
}
}

function getView(testName) {


Laddar…
Avbryt
Spara