Kaynağa Gözat

more robust type detection, thanks again Doug

tags/0.2.3
Jan Lehnardt 16 yıl önce
ebeveyn
işleme
62efd014fc
3 değiştirilmiş dosya ile 25 ekleme ve 9 silme
  1. +3
    -0
      CHANGES.md
  2. +1
    -0
      THANKS.md
  3. +21
    -9
      mustache.js

+ 3
- 0
CHANGES.md Dosyayı Görüntüle

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

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

## 0.2.2 (11-02-2010)

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


+ 1
- 0
THANKS.md Dosyayı Görüntüle

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

+ 21
- 9
mustache.js Dosyayı Görüntüle

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

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({
name: "mustache.js",
version: "0.2.2",
version: "0.2.3-dev",

/*
Turns a template and view into HTML


Yükleniyor…
İptal
Kaydet