ソースを参照

Merge remote-tracking branch 'upstream/master'

Conflicts:
	mustache.js
	spec/_files/escaped.txt
	test/_files/escaped.js
tags/0.5.2
Michael Jackson 14年前
コミット
6171fe9348
7個のファイルの変更26行の追加18行の削除
  1. +3
    -2
      mustache.js
  2. +2
    -2
      test/_files/dot_notation.js
  3. +2
    -2
      test/_files/dot_notation.txt
  4. +1
    -1
      test/_files/escaped.js
  5. +1
    -1
      test/_files/escaped.txt
  6. +1
    -1
      wrappers/qooxdoo/mustache.js.post
  7. +16
    -9
      wrappers/qooxdoo/mustache.js.pre

+ 3
- 2
mustache.js ファイルの表示

@@ -59,11 +59,12 @@ var Mustache = (typeof module !== "undefined" && module.exports) || {};
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;'
"'": '&#39;',
"/": '&#x2F;'
};

function escapeHtml(string) {
return String(string).replace(/[&<>"']/g, function (s) {
return String(string).replace(/[&<>"'\/]/g, function (s) {
return entityMap[s];
});
}


+ 2
- 2
test/_files/dot_notation.js ファイルの表示

@@ -7,8 +7,8 @@
return this.value * 0.2;
},
currency: {
symbol: '&euro;',
name: 'Euro'
symbol: '$',
name: 'USD'
}
},
availability: {


+ 2
- 2
test/_files/dot_notation.txt ファイルの表示

@@ -1,8 +1,8 @@
<!-- exciting part -->
<h1>A Book</h1>
<p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p>
<p>Price: &euro;200 Euro <b>In Stock</b></p>
<p>VAT: &euro;40</p>
<p>Price: $200 USD <b>In Stock</b></p>
<p>VAT: $40</p>
<!-- boring part -->
<h2>Test truthy false values:</h2>
<p>Zero: 0</p>


+ 1
- 1
test/_files/escaped.js ファイルの表示

@@ -2,5 +2,5 @@
title: function () {
return "Bear > Shark";
},
entities: "&quot;"
entities: "&quot; \"'<>/"
})

+ 1
- 1
test/_files/escaped.txt ファイルの表示

@@ -1,2 +1,2 @@
<h1>Bear &gt; Shark</h1>
And even &amp;quot;, but not &quot;.
And even &amp;quot; &quot;&#39;&lt;&gt;&#x2F;, but not &quot; "'<>/.

+ 1
- 1
wrappers/qooxdoo/mustache.js.post ファイルの表示

@@ -4,6 +4,6 @@

// EXPOSE qooxdoo variant
qx.bom.Template.version = Mustache.version;
qx.bom.Template.toHtml = Mustache.render;
qx.bom.Template.render = Mustache.render;

})();

+ 16
- 9
wrappers/qooxdoo/mustache.js.pre ファイルの表示

@@ -5,7 +5,7 @@
http://qooxdoo.org

Copyright:
2004-2011 1&1 Internet AG, Germany, http://www.1und1.de
2004-2012 1&1 Internet AG, Germany, http://www.1und1.de

License:
LGPL: http://www.gnu.org/licenses/lgpl.html
@@ -74,7 +74,7 @@
* For further details, please visit the mustache.js documentation here:
* https://github.com/janl/mustache.js/blob/master/README.md
*/
qx.Class.define("qx.bom.Template", {
qx.Bootstrap.define("qx.bom.Template", {
statics : {
/** Contains the mustache.js version. */
version: null,
@@ -83,21 +83,21 @@ qx.Class.define("qx.bom.Template", {
* Original and only template method of mustache.js. For further
* documentation, please visit https://github.com/janl/mustache.js
*
* @signature function(template, view, partials, send_fun)
* @signature function(template, view, partials)
* @param template {String} The String containing the template.
* @param view {Object} The object holding the data to render.
* @param partials {Object} Object holding parts of a template.
* @param send_fun {Function?} Callback function for streaming.
* @return {String} The parsed template.
*/
toHtml: null,
render: null,


/**
* Helper method which provides you with a direct access to templates
* stored as HTML in the DOM. The DOM node with the given ID will be reated
* stored as HTML in the DOM. The DOM node with the given ID will be used
* as a template, parsed and a new DOM node will be returned containing the
* parsed data.
* parsed data. Keep in mind to have only one root DOM element in the the
* template.
*
* @param id {String} The id of the HTML template in the DOM.
* @param view {Object} The object holding the data to render.
@@ -105,14 +105,22 @@ qx.Class.define("qx.bom.Template", {
* @return {DomNode} A DOM element holding the parsed template data.
*/
get : function(id, view, partials) {
// get the content stored in the DOM
var template = document.getElementById(id);
var inner = template.innerHTML;

// apply the view
inner = this.toHtml(inner, view, partials);

// special case for text only conversion
if (inner.search(/<|>/) === -1) {
return inner;
}

// create a helper to convert the string into DOM nodes
var helper = qx.bom.Element.create("div");
helper.innerHTML = inner;
return helper.children[0];
}
}
@@ -124,4 +132,3 @@ qx.Class.define("qx.bom.Template", {
* Below is the original mustache.js code. Snapshot date is mentioned in
* the head of this file.
*/

読み込み中…
キャンセル
保存