Sfoglia il codice sorgente

wrap code comments explaining , and use a different example

pull/618/head
raymond.lam 9 anni fa
parent
commit
bd12d95eb5
1 ha cambiato i file con 14 aggiunte e 7 eliminazioni
  1. +14
    -7
      mustache.js

+ 14
- 7
mustache.js Vedi File

@@ -428,16 +428,23 @@
intermediateValue = context.view[name]; intermediateValue = context.view[name];


/** /**
* Only checking against hasProperty, which always returns false if
* context.view is not an object. Deliberately omitting the check
* against primitiveHasOwnProperty if dot notation is not used.
* Only checking against `hasProperty`, which always returns `false` if
* `context.view` is not an object. Deliberately omitting the check
* against `primitiveHasOwnProperty` if dot notation is not used.
* *
* Consider this example: * Consider this example:
* Mustache.render("{{#length}}{{length}}{{/length}}", {length: "hello"})
* ```
* Mustache.render("The length of a football field is {{#length}}{{length}}{{/length}}.", {length: "100 yards"})
* ```
* *
* If we were to check also against primitiveHasOwnProperty, as we do
* in the dot notation case, then render call would return 5, rather
* than the expected "hello".
* If we were to check also against `primitiveHasOwnProperty`, as we do
* in the dot notation case, then render call would return:
*
* "The length of a football field is 9."
*
* rather than the expected:
*
* "The length of a football field is 100 yards."
**/ **/
lookupHit = hasProperty(context.view, name); lookupHit = hasProperty(context.view, name);
} }


Loading…
Annulla
Salva