Skip to content

Commit d87d274

Browse files
committed
Merge pull request janl#129 from wittemann/master
Add qooxdoo wrapper. Use `make qooxdoo`.
2 parents cc7bc5f + acb4695 commit d87d274

File tree

4 files changed

+140
-1
lines changed

4 files changed

+140
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Or just install it as a RubyGem:
285285
[couchdb]: http://couchdb.apache.org
286286

287287

288-
## Plugins for jQuery, Dojo, Yui, CommonJS
288+
## Plugins for jQuery, Dojo, Yui, CommonJS, qooxdoo
289289

290290
This repository lets you build modules for [jQuery][], [Dojo][], [Yui][] and
291291
[CommonJS][] / [Node.js][] with the help of `rake`. You may need to install
@@ -303,6 +303,8 @@ directory.
303303
Run `rake commonjs` to get a CommonJS compatible plugin file in the
304304
`mustache-commonjs/` directory which you can also use with [Node.js][].
305305

306+
Run `rake qooxdoo` to get a qooxdoo compatible file named `qooxdoo.mustache.js`.
307+
306308
## Testing
307309

308310
To run the mustache.js test suite, run `rake spec`. All specs will be run first with JavaScriptCore (using `jsc`)

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ end
4242

4343
templated_build "CommonJS", :location => "lib", :extra => "package.json"
4444
templated_build "jQuery"
45+
templated_build "qooxdoo"
4546
templated_build "Dojo", :location => "dojox/string"
4647
templated_build "YUI3", :location => "yui3/mustache"
4748
templated_build "requirejs"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Above is the original mustache code.
3+
*/
4+
5+
// EXPOSE qooxdoo variant
6+
qx.bom.Template.version = Mustache.version;
7+
qx.bom.Template.toHtml = Mustache.to_html;
8+
9+
})();
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/* ************************************************************************
2+
3+
qooxdoo - the new era of web development
4+
5+
http://qooxdoo.org
6+
7+
Copyright:
8+
2004-2011 1&1 Internet AG, Germany, http://www.1und1.de
9+
10+
License:
11+
LGPL: http://www.gnu.org/licenses/lgpl.html
12+
EPL: http://www.eclipse.org/org/documents/epl-v10.php
13+
See the LICENSE file in the project's top-level directory for details.
14+
15+
Authors:
16+
* Martin Wittemann (martinwittemann)
17+
18+
======================================================================
19+
20+
This class contains code based on the following work:
21+
22+
* Mustache.js version 0.4.0-dev
23+
24+
Code:
25+
https://github.com/janl/mustache.js
26+
27+
Copyright:
28+
(c) 2009 Chris Wanstrath (Ruby)
29+
(c) 2010 Jan Lehnardt (JavaScript)
30+
31+
License:
32+
MIT: http://www.opensource.org/licenses/mit-license.php
33+
34+
----------------------------------------------------------------------
35+
36+
Copyright (c) 2009 Chris Wanstrath (Ruby)
37+
Copyright (c) 2010 Jan Lehnardt (JavaScript)
38+
39+
Permission is hereby granted, free of charge, to any person obtaining
40+
a copy of this software and associated documentation files (the
41+
"Software"), to deal in the Software without restriction, including
42+
without limitation the rights to use, copy, modify, merge, publish,
43+
distribute, sublicense, and/or sell copies of the Software, and to
44+
permit persons to whom the Software is furnished to do so, subject to
45+
the following conditions:
46+
47+
The above copyright notice and this permission notice shall be
48+
included in all copies or substantial portions of the Software.
49+
50+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
51+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
52+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
53+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
54+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
55+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
56+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
57+
58+
************************************************************************ */
59+
60+
/**
61+
* The is a template class which can be used for HTML templating. In fact,
62+
* this is a wrapper for mustache.js which is a "framework-agnostic way to
63+
* render logic-free views".
64+
*
65+
* Here is a basic example how to use it:
66+
* Template:
67+
* <pre>
68+
* var template = "Hi, my name is {{name}}!";
69+
* var view = {name: "qooxdoo"};
70+
* qx.bom.Template.toHtml(template, view);
71+
* // return "Hi, my name is qooxdoo!"
72+
* </pre>
73+
*
74+
* For further details, please visit the mustache.js documentation here:
75+
* https://github.com/janl/mustache.js/blob/master/README.md
76+
*/
77+
qx.Class.define("qx.bom.Template", {
78+
statics : {
79+
/** Contains the mustache.js version. */
80+
version: null,
81+
82+
/**
83+
* Original and only template method of mustache.js. For further
84+
* documentation, please visit https://github.com/janl/mustache.js
85+
*
86+
* @signature function(template, view, partials, send_fun)
87+
* @param template {String} The String containing the template.
88+
* @param view {Object} The object holding the data to render.
89+
* @param partials {Object} Object holding parts of a template.
90+
* @param send_fun {Function?} Callback function for streaming.
91+
* @return {String} The parsed template.
92+
*/
93+
toHtml: null,
94+
95+
96+
/**
97+
* Helper method which provides you with a direct access to templates
98+
* stored as HTML in the DOM. The DOM node with the given ID will be reated
99+
* as a template, parsed and a new DOM node will be returned containing the
100+
* parsed data.
101+
*
102+
* @param id {String} The id of the HTML template in the DOM.
103+
* @param view {Object} The object holding the data to render.
104+
* @param partials {Object} Object holding parts of a template.
105+
* @return {DomNode} A DOM element holding the parsed template data.
106+
*/
107+
get : function(id, view, partials) {
108+
var template = document.getElementById(id);
109+
var inner = template.innerHTML;
110+
111+
inner = this.toHtml(inner, view, partials);
112+
113+
var helper = qx.bom.Element.create("div");
114+
helper.innerHTML = inner;
115+
116+
return helper.children[0];
117+
}
118+
}
119+
});
120+
121+
(function() {
122+
123+
/**
124+
* Below is the original mustache.js code. Snapshot date is mentioned in
125+
* the head of this file.
126+
*/
127+

0 commit comments

Comments
 (0)