Просмотр исходного кода

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 лет назад
Родитель
Сommit
32935dc09b
6 измененных файлов: 25 добавлений и 2 удалений
  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 Просмотреть файл

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


npm-debug.log

+ 1
- 1
mustache.js Просмотреть файл

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


+ 8
- 0
test/_files/implicit_iterator.js Просмотреть файл

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

+ 7
- 0
test/_files/implicit_iterator.mustache Просмотреть файл

@@ -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 Просмотреть файл

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

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

+ 5
- 1
test/render-test.js Просмотреть файл

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


function getContents(testName, ext) { 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) { function getView(testName) {


Загрузка…
Отмена
Сохранить