jazz-jss 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/dist/handlebars/handlebars.js +1493 -0
- data/dist/hashchange/{jquery.ba-hashchange.js → hashchange.js} +0 -0
- data/dist/jazz/lib/controller.js +1 -1
- data/dist/jazz/lib/core.js +3 -0
- data/dist/jazz/lib/db.js +1 -1
- data/dist/jazz/lib/helper.js +2 -1
- data/dist/jazz/lib/model.js +11 -4
- data/dist/jazz/lib/view.js +1 -1
- data/dist/jazz/module.js +15 -0
- data/dist/jquery/jquery.js +0 -0
- data/dist/require/require.js +0 -0
- data/dist/require/template.js +98 -0
- data/dist/underscore/underscore.js +0 -0
- data/lib/jazz/app_detector.rb +6 -3
- data/lib/jazz/app_generator.rb +12 -8
- data/lib/jazz/helper_generator.rb +30 -0
- data/lib/jazz/scaffold_generator.rb +4 -0
- data/templates/app_root/Rakefile +11 -0
- data/templates/app_root/{app → development/app}/assets/javascripts/application.js +0 -0
- data/templates/app_root/{app → development/app}/assets/stylesheets/application.css +0 -0
- data/templates/app_root/development/app/controllers/application_controller.js +11 -0
- data/templates/app_root/development/app/helpers/application_helper.js +7 -0
- data/templates/app_root/development/config/glue.js +9 -0
- data/templates/app_root/development/config/routes.js +5 -0
- data/templates/app_root/scripts/build.js +30 -0
- data/templates/app_root/scripts/r.js/LICENSE +58 -0
- data/templates/app_root/scripts/r.js/README.md +177 -0
- data/templates/app_root/scripts/r.js/build/build.js +26 -0
- data/templates/app_root/scripts/r.js/build/buildebug.sh +4 -0
- data/templates/app_root/scripts/r.js/build/example.build.js +296 -0
- data/templates/app_root/scripts/r.js/build/jslib/blank.js +4 -0
- data/templates/app_root/scripts/r.js/build/jslib/build.js +952 -0
- data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +23 -0
- data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +152 -0
- data/templates/app_root/scripts/r.js/build/jslib/env.js +47 -0
- data/templates/app_root/scripts/r.js/build/jslib/lang.js +49 -0
- data/templates/app_root/scripts/r.js/build/jslib/logger.js +58 -0
- data/templates/app_root/scripts/r.js/build/jslib/node.js +106 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/args.js +20 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/file.js +263 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/load.js +17 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +10 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/print.js +16 -0
- data/templates/app_root/scripts/r.js/build/jslib/optimize.js +279 -0
- data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +11 -0
- data/templates/app_root/scripts/r.js/build/jslib/parse.js +590 -0
- data/templates/app_root/scripts/r.js/build/jslib/pragma.js +251 -0
- data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +286 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino.js +22 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +21 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +244 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +12 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +100 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +12 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +16 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +21 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +1342 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +2005 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +55 -0
- data/templates/app_root/scripts/r.js/build/jslib/x.js +243 -0
- data/templates/app_root/scripts/r.js/build/tests/all.js +47 -0
- data/templates/app_root/scripts/r.js/build/tests/allj.sh +3 -0
- data/templates/app_root/scripts/r.js/build/tests/alln.sh +18 -0
- data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +19 -0
- data/templates/app_root/scripts/r.js/build/tests/builds.js +489 -0
- data/templates/app_root/scripts/r.js/build/tests/circular.build.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/convert.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/css.build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +4 -0
- data/templates/app_root/scripts/r.js/build/tests/css/master.css +10 -0
- data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +7 -0
- data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +13 -0
- data/templates/app_root/scripts/r.js/build/tests/end.frag +3 -0
- data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +23 -0
- data/templates/app_root/scripts/r.js/build/tests/exports.build.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +30 -0
- data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +70 -0
- data/templates/app_root/scripts/r.js/build/tests/http/main.html +28 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +58 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +188 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +21 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +15 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +47 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +14 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +42 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +21 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +31 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +24 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +24 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +25 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +31 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +29 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/order.build.js +16 -0
- data/templates/app_root/scripts/r.js/build/tests/override/override.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/packages.build.js +59 -0
- data/templates/app_root/scripts/r.js/build/tests/parse.js +103 -0
- data/templates/app_root/scripts/r.js/build/tests/simple.build.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/start.frag +4 -0
- data/templates/app_root/scripts/r.js/build/tests/text.build.js +16 -0
- data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +16 -0
- data/templates/app_root/scripts/r.js/dist.js +95 -0
- data/templates/app_root/scripts/r.js/dist/README.md +6 -0
- data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +9042 -0
- data/templates/app_root/scripts/r.js/dist/r-edge.js +9191 -0
- data/templates/app_root/scripts/r.js/dist/r.js +9099 -0
- data/templates/app_root/scripts/r.js/lib/closure/COPYING +202 -0
- data/templates/app_root/scripts/r.js/lib/closure/README +292 -0
- data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
- data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +4 -0
- data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
- data/templates/app_root/scripts/r.js/require.js +1952 -0
- data/templates/app_root/scripts/r.js/tasks.txt +2 -0
- data/templates/app_root/scripts/r.js/tests/all.js +49 -0
- data/templates/app_root/scripts/r.js/tests/allNode.js +3 -0
- data/templates/app_root/scripts/r.js/tests/allj.sh +1 -0
- data/templates/app_root/scripts/r.js/tests/alln.sh +2 -0
- data/templates/app_root/scripts/r.js/tests/alpha.js +3 -0
- data/templates/app_root/scripts/r.js/tests/beta.js +6 -0
- data/templates/app_root/scripts/r.js/tests/doh/LICENSE +195 -0
- data/templates/app_root/scripts/r.js/tests/doh/README +12 -0
- data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +855 -0
- data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +20 -0
- data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +17 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +10 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.html +316 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.js +1499 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.sh +3 -0
- data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
- data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +39 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +15 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +1 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +13 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +13 -0
- data/templates/app_root/scripts/r.js/tests/node/index.js +11 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +6 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +9 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +3 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/server.js +11 -0
- data/templates/app_root/scripts/r.js/tests/relative.js +10 -0
- data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +3 -0
- data/templates/application.js +6 -5
- data/templates/boot.js +42 -0
- data/templates/helper.js +9 -0
- data/templates/index.html +1 -1
- metadata +201 -11
- data/dist/jazz/main.js +0 -65
- data/dist/mustache/mustache.js +0 -324
- data/templates/app_root/config/routes.js +0 -4
- data/templates/glue.js +0 -4
data/dist/jazz/main.js
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
var Jazz = {
|
2
|
-
_:{
|
3
|
-
_app: "",
|
4
|
-
_files: [
|
5
|
-
'vendor/jquery/jquery.js',
|
6
|
-
'vendor/hashchange/jquery.ba-hashchange.js',
|
7
|
-
'vendor/mustache/mustache.js',
|
8
|
-
'vendor/underscore/underscore.js',
|
9
|
-
'lib/jazz/lib/helper.js',
|
10
|
-
'lib/jazz/lib/model.js',
|
11
|
-
'lib/jazz/lib/db.js',
|
12
|
-
'lib/jazz/lib/route.js',
|
13
|
-
'lib/jazz/lib/view.js',
|
14
|
-
'lib/jazz/lib/controller.js',
|
15
|
-
'config/application.js',
|
16
|
-
'config/glue.js',
|
17
|
-
'config/routes.js'
|
18
|
-
]
|
19
|
-
},
|
20
|
-
|
21
|
-
Helper: function(){},
|
22
|
-
Now: {},
|
23
|
-
initialize: function(){
|
24
|
-
this.load(
|
25
|
-
glue,
|
26
|
-
function(){
|
27
|
-
window[Jazz._._app].initialize();
|
28
|
-
Jazz.Route.initialize();
|
29
|
-
}
|
30
|
-
);
|
31
|
-
},
|
32
|
-
|
33
|
-
load: function(path, callback){
|
34
|
-
|
35
|
-
if (!path) return this;
|
36
|
-
|
37
|
-
files = [];
|
38
|
-
|
39
|
-
if (typeof path == "string")
|
40
|
-
files.push(path);
|
41
|
-
else
|
42
|
-
files = path;
|
43
|
-
|
44
|
-
for (file in files) {
|
45
|
-
files[file] = 'vendor/require/order!' + files[file];
|
46
|
-
}
|
47
|
-
|
48
|
-
require(
|
49
|
-
{
|
50
|
-
baseUrl:""
|
51
|
-
},
|
52
|
-
files,
|
53
|
-
callback
|
54
|
-
);
|
55
|
-
},
|
56
|
-
|
57
|
-
setup: function(name){
|
58
|
-
//Set Appname
|
59
|
-
this._._app = name;
|
60
|
-
}
|
61
|
-
}
|
62
|
-
|
63
|
-
Jazz.load(Jazz._._files, function(){
|
64
|
-
Jazz.initialize();
|
65
|
-
});
|
data/dist/mustache/mustache.js
DELETED
@@ -1,324 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
mustache.js — Logic-less templates in JavaScript
|
3
|
-
|
4
|
-
See http://mustache.github.com/ for more info.
|
5
|
-
*/
|
6
|
-
|
7
|
-
var Mustache = function() {
|
8
|
-
var Renderer = function() {};
|
9
|
-
|
10
|
-
Renderer.prototype = {
|
11
|
-
otag: "{{",
|
12
|
-
ctag: "}}",
|
13
|
-
pragmas: {},
|
14
|
-
buffer: [],
|
15
|
-
pragmas_implemented: {
|
16
|
-
"IMPLICIT-ITERATOR": true
|
17
|
-
},
|
18
|
-
context: {},
|
19
|
-
|
20
|
-
render: function(template, context, partials, in_recursion) {
|
21
|
-
// reset buffer & set context
|
22
|
-
if(!in_recursion) {
|
23
|
-
this.context = context;
|
24
|
-
this.buffer = []; // TODO: make this non-lazy
|
25
|
-
}
|
26
|
-
|
27
|
-
// fail fast
|
28
|
-
if(!this.includes("", template)) {
|
29
|
-
if(in_recursion) {
|
30
|
-
return template;
|
31
|
-
} else {
|
32
|
-
this.send(template);
|
33
|
-
return;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
template = this.render_pragmas(template);
|
38
|
-
var html = this.render_section(template, context, partials);
|
39
|
-
if(in_recursion) {
|
40
|
-
return this.render_tags(html, context, partials, in_recursion);
|
41
|
-
}
|
42
|
-
|
43
|
-
this.render_tags(html, context, partials, in_recursion);
|
44
|
-
},
|
45
|
-
|
46
|
-
/*
|
47
|
-
Sends parsed lines
|
48
|
-
*/
|
49
|
-
send: function(line) {
|
50
|
-
if(line != "") {
|
51
|
-
this.buffer.push(line);
|
52
|
-
}
|
53
|
-
},
|
54
|
-
|
55
|
-
/*
|
56
|
-
Looks for %PRAGMAS
|
57
|
-
*/
|
58
|
-
render_pragmas: function(template) {
|
59
|
-
// no pragmas
|
60
|
-
if(!this.includes("%", template)) {
|
61
|
-
return template;
|
62
|
-
}
|
63
|
-
|
64
|
-
var that = this;
|
65
|
-
var regex = new RegExp(this.otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" +
|
66
|
-
this.ctag);
|
67
|
-
return template.replace(regex, function(match, pragma, options) {
|
68
|
-
if(!that.pragmas_implemented[pragma]) {
|
69
|
-
throw({message:
|
70
|
-
"This implementation of mustache doesn't understand the '" +
|
71
|
-
pragma + "' pragma"});
|
72
|
-
}
|
73
|
-
that.pragmas[pragma] = {};
|
74
|
-
if(options) {
|
75
|
-
var opts = options.split("=");
|
76
|
-
that.pragmas[pragma][opts[0]] = opts[1];
|
77
|
-
}
|
78
|
-
return "";
|
79
|
-
// ignore unknown pragmas silently
|
80
|
-
});
|
81
|
-
},
|
82
|
-
|
83
|
-
/*
|
84
|
-
Tries to find a partial in the curent scope and render it
|
85
|
-
*/
|
86
|
-
render_partial: function(name, context, partials) {
|
87
|
-
name = this.trim(name);
|
88
|
-
if(!partials || partials[name] === undefined) {
|
89
|
-
throw({message: "unknown_partial '" + name + "'"});
|
90
|
-
}
|
91
|
-
if(typeof(context[name]) != "object") {
|
92
|
-
return this.render(partials[name], context, partials, true);
|
93
|
-
}
|
94
|
-
return this.render(partials[name], context[name], partials, true);
|
95
|
-
},
|
96
|
-
|
97
|
-
/*
|
98
|
-
Renders inverted (^) and normal (#) sections
|
99
|
-
*/
|
100
|
-
render_section: function(template, context, partials) {
|
101
|
-
if(!this.includes("#", template) && !this.includes("^", template)) {
|
102
|
-
return template;
|
103
|
-
}
|
104
|
-
|
105
|
-
var that = this;
|
106
|
-
// CSW - Added "+?" so it finds the tighest bound, not the widest
|
107
|
-
var regex = new RegExp(this.otag + "(\\^|\\#)\\s*(.+)\\s*" + this.ctag +
|
108
|
-
"\n*([\\s\\S]+?)" + this.otag + "\\/\\s*\\2\\s*" + this.ctag +
|
109
|
-
"\\s*", "mg");
|
110
|
-
|
111
|
-
// for each {{#foo}}{{/foo}} section do...
|
112
|
-
return template.replace(regex, function(match, type, name, content) {
|
113
|
-
var value = that.find(name, context);
|
114
|
-
if(type == "^") { // inverted section
|
115
|
-
if(!value || that.is_array(value) && value.length === 0) {
|
116
|
-
// false or empty list, render it
|
117
|
-
return that.render(content, context, partials, true);
|
118
|
-
} else {
|
119
|
-
return "";
|
120
|
-
}
|
121
|
-
} else if(type == "#") { // normal section
|
122
|
-
if(that.is_array(value)) { // Enumerable, Let's loop!
|
123
|
-
return that.map(value, function(row) {
|
124
|
-
return that.render(content, that.create_context(row),
|
125
|
-
partials, true);
|
126
|
-
}).join("");
|
127
|
-
} else if(that.is_object(value)) { // Object, Use it as subcontext!
|
128
|
-
return that.render(content, that.create_context(value),
|
129
|
-
partials, true);
|
130
|
-
} else if(typeof value === "function") {
|
131
|
-
// higher order section
|
132
|
-
return value.call(context, content, function(text) {
|
133
|
-
return that.render(text, context, partials, true);
|
134
|
-
});
|
135
|
-
} else if(value) { // boolean section
|
136
|
-
return that.render(content, context, partials, true);
|
137
|
-
} else {
|
138
|
-
return "";
|
139
|
-
}
|
140
|
-
}
|
141
|
-
});
|
142
|
-
},
|
143
|
-
|
144
|
-
/*
|
145
|
-
Replace {{foo}} and friends with values from our view
|
146
|
-
*/
|
147
|
-
render_tags: function(template, context, partials, in_recursion) {
|
148
|
-
// tit for tat
|
149
|
-
var that = this;
|
150
|
-
|
151
|
-
var new_regex = function() {
|
152
|
-
return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?" +
|
153
|
-
that.ctag + "+", "g");
|
154
|
-
};
|
155
|
-
|
156
|
-
var regex = new_regex();
|
157
|
-
var tag_replace_callback = function(match, operator, name) {
|
158
|
-
switch(operator) {
|
159
|
-
case "!": // ignore comments
|
160
|
-
return "";
|
161
|
-
case "=": // set new delimiters, rebuild the replace regexp
|
162
|
-
that.set_delimiters(name);
|
163
|
-
regex = new_regex();
|
164
|
-
return "";
|
165
|
-
case ">": // render partial
|
166
|
-
return that.render_partial(name, context, partials);
|
167
|
-
case "{": // the triple mustache is unescaped
|
168
|
-
return that.find(name, context);
|
169
|
-
default: // escape the value
|
170
|
-
return that.escape(that.find(name, context));
|
171
|
-
}
|
172
|
-
};
|
173
|
-
var lines = template.split("\n");
|
174
|
-
for(var i = 0; i < lines.length; i++) {
|
175
|
-
lines[i] = lines[i].replace(regex, tag_replace_callback, this);
|
176
|
-
if(!in_recursion) {
|
177
|
-
this.send(lines[i]);
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
if(in_recursion) {
|
182
|
-
return lines.join("\n");
|
183
|
-
}
|
184
|
-
},
|
185
|
-
|
186
|
-
set_delimiters: function(delimiters) {
|
187
|
-
var dels = delimiters.split(" ");
|
188
|
-
this.otag = this.escape_regex(dels[0]);
|
189
|
-
this.ctag = this.escape_regex(dels[1]);
|
190
|
-
},
|
191
|
-
|
192
|
-
escape_regex: function(text) {
|
193
|
-
// thank you Simon Willison
|
194
|
-
if(!arguments.callee.sRE) {
|
195
|
-
var specials = [
|
196
|
-
'/', '.', '*', '+', '?', '|',
|
197
|
-
'(', ')', '[', ']', '{', '}', '\\'
|
198
|
-
];
|
199
|
-
arguments.callee.sRE = new RegExp(
|
200
|
-
'(\\' + specials.join('|\\') + ')', 'g'
|
201
|
-
);
|
202
|
-
}
|
203
|
-
return text.replace(arguments.callee.sRE, '\\$1');
|
204
|
-
},
|
205
|
-
|
206
|
-
/*
|
207
|
-
find `name` in current `context`. That is find me a value
|
208
|
-
from the view object
|
209
|
-
*/
|
210
|
-
find: function(name, context) {
|
211
|
-
name = this.trim(name);
|
212
|
-
|
213
|
-
// Checks whether a value is thruthy or false or 0
|
214
|
-
function is_kinda_truthy(bool) {
|
215
|
-
return bool === false || bool === 0 || bool;
|
216
|
-
}
|
217
|
-
|
218
|
-
var value;
|
219
|
-
if(is_kinda_truthy(context[name])) {
|
220
|
-
value = context[name];
|
221
|
-
} else if(is_kinda_truthy(this.context[name])) {
|
222
|
-
value = this.context[name];
|
223
|
-
}
|
224
|
-
|
225
|
-
if(typeof value === "function") {
|
226
|
-
return value.apply(context);
|
227
|
-
}
|
228
|
-
if(value !== undefined) {
|
229
|
-
return value;
|
230
|
-
}
|
231
|
-
// silently ignore unkown variables
|
232
|
-
return "";
|
233
|
-
},
|
234
|
-
|
235
|
-
// Utility methods
|
236
|
-
|
237
|
-
/* includes tag */
|
238
|
-
includes: function(needle, haystack) {
|
239
|
-
return haystack.indexOf(this.otag + needle) != -1;
|
240
|
-
},
|
241
|
-
|
242
|
-
/*
|
243
|
-
Does away with nasty characters
|
244
|
-
*/
|
245
|
-
escape: function(s) {
|
246
|
-
s = String(s === null ? "" : s);
|
247
|
-
return s.replace(/&(?!\w+;)|["<>\\]/g, function(s) {
|
248
|
-
switch(s) {
|
249
|
-
case "&": return "&";
|
250
|
-
case "\\": return "\\\\";
|
251
|
-
case '"': return '\"';
|
252
|
-
case "<": return "<";
|
253
|
-
case ">": return ">";
|
254
|
-
default: return s;
|
255
|
-
}
|
256
|
-
});
|
257
|
-
},
|
258
|
-
|
259
|
-
// by @langalex, support for arrays of strings
|
260
|
-
create_context: function(_context) {
|
261
|
-
if(this.is_object(_context)) {
|
262
|
-
return _context;
|
263
|
-
} else {
|
264
|
-
var iterator = ".";
|
265
|
-
if(this.pragmas["IMPLICIT-ITERATOR"]) {
|
266
|
-
iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
|
267
|
-
}
|
268
|
-
var ctx = {};
|
269
|
-
ctx[iterator] = _context;
|
270
|
-
return ctx;
|
271
|
-
}
|
272
|
-
},
|
273
|
-
|
274
|
-
is_object: function(a) {
|
275
|
-
return a && typeof a == "object";
|
276
|
-
},
|
277
|
-
|
278
|
-
is_array: function(a) {
|
279
|
-
return Object.prototype.toString.call(a) === '[object Array]';
|
280
|
-
},
|
281
|
-
|
282
|
-
/*
|
283
|
-
Gets rid of leading and trailing whitespace
|
284
|
-
*/
|
285
|
-
trim: function(s) {
|
286
|
-
return s.replace(/^\s*|\s*$/g, "");
|
287
|
-
},
|
288
|
-
|
289
|
-
/*
|
290
|
-
Why, why, why? Because IE. Cry, cry cry.
|
291
|
-
*/
|
292
|
-
map: function(array, fn) {
|
293
|
-
if (typeof array.map == "function") {
|
294
|
-
return array.map(fn);
|
295
|
-
} else {
|
296
|
-
var r = [];
|
297
|
-
var l = array.length;
|
298
|
-
for(var i = 0; i < l; i++) {
|
299
|
-
r.push(fn(array[i]));
|
300
|
-
}
|
301
|
-
return r;
|
302
|
-
}
|
303
|
-
}
|
304
|
-
};
|
305
|
-
|
306
|
-
return({
|
307
|
-
name: "mustache.js",
|
308
|
-
version: "0.3.0",
|
309
|
-
|
310
|
-
/*
|
311
|
-
Turns a template and view into HTML
|
312
|
-
*/
|
313
|
-
to_html: function(template, view, partials, send_fun) {
|
314
|
-
var renderer = new Renderer();
|
315
|
-
if(send_fun) {
|
316
|
-
renderer.send = send_fun;
|
317
|
-
}
|
318
|
-
renderer.render(template, view, partials);
|
319
|
-
if(!send_fun) {
|
320
|
-
return renderer.buffer.join("\n");
|
321
|
-
}
|
322
|
-
}
|
323
|
-
});
|
324
|
-
}();
|
data/templates/glue.js
DELETED