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

more robust type detection, thanks again Doug

tags/0.2.3
Jan Lehnardt 16 лет назад
Родитель
Сommit
62efd014fc
3 измененных файлов: 25 добавлений и 9 удалений
  1. +3
    -0
      CHANGES.md
  2. +1
    -0
      THANKS.md
  3. +21
    -9
      mustache.js

+ 3
- 0
CHANGES.md Просмотреть файл

@@ -1,5 +1,8 @@
# mustache.js Changes # mustache.js Changes


## 0.2.3 (??-??-????)
* Added more robust type detection.

## 0.2.2 (11-02-2010) ## 0.2.2 (11-02-2010)


* ctemplate compat: Partials are indicated by >, not <. * ctemplate compat: Partials are indicated by >, not <.


+ 1
- 0
THANKS.md Просмотреть файл

@@ -8,3 +8,4 @@ Mustache.js wouldn't kick ass if it weren't for these fine souls
* J Chris Anderson / jchris * J Chris Anderson / jchris
* Tom Robinson / tlrobinson * Tom Robinson / tlrobinson
* Aaron Quint / quirkey * Aaron Quint / quirkey
* Douglas Crockford

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

@@ -238,18 +238,30 @@ var Mustache = function() {
}, },


is_object: function(a) { is_object: function(a) {
return a && typeof a == "object"
return this.typeOf(a) === "object";
},

is_array: function(a) {
return this.typeOf(a) === "array";
}, },


/* /*
Thanks Doug Crockford
JavaScript — The Good Parts lists an alternative that works better with
frames. Frames can suck it, we use the simple version.
Thanks Doug Crockford http://javascript.crockford.com/remedial.html
*/ */
is_array: function(a) {
return (a &&
typeof a === "object" &&
a.constructor === Array);
typeOf: function(value) {
var s = typeof value;
if(s === "object") {
if(value) {
if(typeof value.length === "number" &&
!(value.propertyIsEnumerable("length")) &&
typeof value.splice === "function") {
s = "array";
}
} else {
s = "null";
}
}
return s;
}, },


/* /*
@@ -278,7 +290,7 @@ var Mustache = function() {


return({ return({
name: "mustache.js", name: "mustache.js",
version: "0.2.2",
version: "0.2.3-dev",


/* /*
Turns a template and view into HTML Turns a template and view into HTML


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