cmstyle 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/app/assets/images/cm_app.ico +0 -0
- data/lib/app/assets/images/cm_app.png +0 -0
- data/lib/app/assets/images/cm_app_30x30.png +0 -0
- data/lib/app/assets/stylesheets/application.css +9 -78
- data/lib/app/views/layouts/_footer.slim +12 -5
- data/lib/app/views/layouts/application.slim +27 -18
- data/lib/assets/images/glyphicons-halflings-white.png +0 -0
- data/lib/assets/images/glyphicons-halflings.png +0 -0
- data/lib/assets/javascripts/bootstrap.js +165 -31
- data/lib/assets/javascripts/prettify.js +0 -0
- data/lib/assets/stylesheets/bootstrap-responsive.css +5 -1
- data/lib/assets/stylesheets/bootstrap.css +335 -189
- data/lib/assets/stylesheets/prettify.css +0 -0
- data/lib/cmstyle.rb +4 -1
- data/lib/cmstyle/navigation_helpers.rb +165 -0
- data/lib/cmstyle/version.rb +1 -1
- metadata +6 -83
- data/lib/app/assets/images/novartis-micro.png +0 -0
- data/lib/app/assets/images/novartis-small.png +0 -0
- data/lib/app/views/cmstyle/_footer.slim +0 -5
- data/lib/app/views/cmstyle/_header.slim +0 -40
- data/lib/app/views/cmstyle/_modals.slim +0 -62
- data/lib/assets/images/8020select.png +0 -0
- data/lib/assets/images/adoptahydrant.png +0 -0
- data/lib/assets/images/apple-touch-icon-114-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-144-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-57-precomposed.png +0 -0
- data/lib/assets/images/apple-touch-icon-72-precomposed.png +0 -0
- data/lib/assets/images/bootstrap-example-carousel.png +0 -0
- data/lib/assets/images/bootstrap-example-fluid.jpg +0 -0
- data/lib/assets/images/bootstrap-example-hero.jpg +0 -0
- data/lib/assets/images/bootstrap-example-marketing-narrow.png +0 -0
- data/lib/assets/images/bootstrap-example-signin.png +0 -0
- data/lib/assets/images/bootstrap-example-starter.jpg +0 -0
- data/lib/assets/images/bootstrap-example-sticky-footer.png +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-01.jpg +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-02.jpg +0 -0
- data/lib/assets/images/bootstrap-mdo-sfmoma-03.jpg +0 -0
- data/lib/assets/images/breakingnews.png +0 -0
- data/lib/assets/images/browser-icon-chrome.png +0 -0
- data/lib/assets/images/browser-icon-firefox.png +0 -0
- data/lib/assets/images/browser-icon-safari.png +0 -0
- data/lib/assets/images/bs-docs-bootstrap-features.png +0 -0
- data/lib/assets/images/bs-docs-masthead-pattern.png +0 -0
- data/lib/assets/images/bs-docs-responsive-illustrations.png +0 -0
- data/lib/assets/images/bs-docs-twitter-github.png +0 -0
- data/lib/assets/images/fleetio.png +0 -0
- data/lib/assets/images/gathercontent.png +0 -0
- data/lib/assets/images/grid-baseline-20px.png +0 -0
- data/lib/assets/images/jshint.png +0 -0
- data/lib/assets/images/kippt.png +0 -0
- data/lib/assets/images/less-logo-large.png +0 -0
- data/lib/assets/images/logo.png +0 -0
- data/lib/assets/images/noise.png +0 -0
- data/lib/assets/images/responsive-illustrations.png +0 -0
- data/lib/assets/images/slide-01.jpg +0 -0
- data/lib/assets/images/slide-02.jpg +0 -0
- data/lib/assets/images/slide-03.jpg +0 -0
- data/lib/assets/images/small-hogan-icon.png +0 -0
- data/lib/assets/images/soundready.png +0 -0
- data/lib/assets/images/stripes.png +0 -0
- data/lib/assets/javascripts/application.js +0 -154
- data/lib/assets/javascripts/bootstrap-affix.js +0 -19
- data/lib/assets/javascripts/bootstrap-alert.js +0 -56
- data/lib/assets/javascripts/bootstrap-button.js +0 -96
- data/lib/assets/javascripts/bootstrap-carousel.js +0 -63
- data/lib/assets/javascripts/bootstrap-collapse.js +0 -88
- data/lib/assets/javascripts/bootstrap-dropdown.js +0 -145
- data/lib/assets/javascripts/bootstrap-modal.js +0 -114
- data/lib/assets/javascripts/bootstrap-phantom.js +0 -21
- data/lib/assets/javascripts/bootstrap-popover.js +0 -107
- data/lib/assets/javascripts/bootstrap-scrollspy.js +0 -31
- data/lib/assets/javascripts/bootstrap-tab.js +0 -80
- data/lib/assets/javascripts/bootstrap-tooltip.js +0 -153
- data/lib/assets/javascripts/bootstrap-transition.js +0 -13
- data/lib/assets/javascripts/bootstrap-typeahead.js +0 -199
- data/lib/assets/javascripts/compiler.js +0 -348
- data/lib/assets/javascripts/hogan-1.0.5.amd.js +0 -576
- data/lib/assets/javascripts/hogan-1.0.5.common.js +0 -576
- data/lib/assets/javascripts/hogan-1.0.5.js +0 -572
- data/lib/assets/javascripts/hogan-1.0.5.mustache.js +0 -619
- data/lib/assets/javascripts/hogan.js +0 -545
- data/lib/assets/javascripts/index.js +0 -848
- data/lib/assets/javascripts/jquery.js +0 -2
- data/lib/assets/javascripts/mustache.js +0 -90
- data/lib/assets/javascripts/phantom.js +0 -63
- data/lib/assets/javascripts/qunit.js +0 -1510
- data/lib/assets/javascripts/release.js +0 -74
- data/lib/assets/javascripts/server.js +0 -14
- data/lib/assets/javascripts/spec.js +0 -77
- data/lib/assets/javascripts/template-1.0.5.js +0 -233
- data/lib/assets/javascripts/template.js +0 -233
- data/lib/assets/javascripts/web_templates.js +0 -32
- data/lib/assets/stylesheets/css-tests.css +0 -139
- data/lib/assets/stylesheets/docs.css +0 -1015
- data/lib/assets/stylesheets/layout.css +0 -206
- data/lib/assets/stylesheets/qunit.css +0 -232
- data/lib/assets/stylesheets/skeleton.css +0 -236
@@ -1,74 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
var fs = require('fs');
|
17
|
-
var path = require('path');
|
18
|
-
var Hogan = require(__dirname + '/../lib/hogan');
|
19
|
-
var minlicense = '/**\n* @preserve Copyright 2012 Twitter, Inc.\n* @license http://www.apache.org/licenses/LICENSE-2.0.txt\n*/\n';
|
20
|
-
|
21
|
-
function read(path) {
|
22
|
-
return fs.readFileSync(path).toString()
|
23
|
-
}
|
24
|
-
|
25
|
-
// Good enough for little js files
|
26
|
-
function copy(src, dst) {
|
27
|
-
return fs.writeFileSync(dst, read(src));
|
28
|
-
}
|
29
|
-
|
30
|
-
function uglify(src, dst) {
|
31
|
-
var jsp = require("uglify-js").parser;
|
32
|
-
var pro = require("uglify-js").uglify;
|
33
|
-
var orig_code = read(src);
|
34
|
-
var ast = jsp.parse(orig_code); // parse code and get the initial AST
|
35
|
-
ast = pro.ast_mangle(ast); // get a new AST with mangled names
|
36
|
-
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
|
37
|
-
fs.writeFileSync(dst, minlicense + pro.gen_code(ast));
|
38
|
-
}
|
39
|
-
|
40
|
-
var packageJSON = JSON.parse(read('package.json'));
|
41
|
-
var version = packageJSON.version.substring(0, packageJSON.version.indexOf('-'));
|
42
|
-
|
43
|
-
function removeFirstComment(text) {
|
44
|
-
return text.substring(text.indexOf('*/') + 2);
|
45
|
-
}
|
46
|
-
|
47
|
-
var context = {
|
48
|
-
template: removeFirstComment(read(__dirname + '/../lib/template.js')),
|
49
|
-
compiler: removeFirstComment(read(__dirname + '/../lib/compiler.js'))
|
50
|
-
};
|
51
|
-
|
52
|
-
var wrapperPath = '/../wrappers/';
|
53
|
-
var wrappers = fs.readdirSync(__dirname + wrapperPath).map(function(f) {
|
54
|
-
return __dirname + wrapperPath + f;
|
55
|
-
});
|
56
|
-
|
57
|
-
var distPath = __dirname + '/../dist/';
|
58
|
-
wrappers.forEach(function(wrapper) {
|
59
|
-
var tail = path.basename(wrapper, '.mustache');
|
60
|
-
var target = distPath + 'hogan-' + version + '.' + tail;
|
61
|
-
var uglified = distPath + 'hogan-' + version + '.min.' + tail;
|
62
|
-
fs.writeFileSync(target, Hogan.compile(read(wrapper)).render(context));
|
63
|
-
uglify(target, uglified);
|
64
|
-
});
|
65
|
-
|
66
|
-
// Also release Hogan.Template on its own.
|
67
|
-
var templateTarget = distPath + 'template-' + version + '.js';
|
68
|
-
fs.writeFileSync(templateTarget, read(__dirname + '/../lib/template.js'));
|
69
|
-
uglify(templateTarget, distPath + 'template-' + version + '.min.js');
|
70
|
-
|
71
|
-
// Add packageJSON to node distribution
|
72
|
-
packageJSON.version = version;
|
73
|
-
fs.writeFileSync(__dirname + '/../dist/nodejs/package.json',
|
74
|
-
JSON.stringify(packageJSON, null, " "));
|
@@ -1,14 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Simple connect server for phantom.js
|
3
|
-
* Adapted from Modernizr
|
4
|
-
*/
|
5
|
-
|
6
|
-
var connect = require('connect')
|
7
|
-
, http = require('http')
|
8
|
-
, fs = require('fs')
|
9
|
-
, app = connect()
|
10
|
-
.use(connect.static(__dirname + '/../../'));
|
11
|
-
|
12
|
-
http.createServer(app).listen(3000);
|
13
|
-
|
14
|
-
fs.writeFileSync(__dirname + '/pid.txt', process.pid, 'utf-8')
|
@@ -1,77 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
var Hogan = Hogan || require('../lib/hogan');
|
17
|
-
var doc = this["document"];
|
18
|
-
var fs = require('fs');
|
19
|
-
|
20
|
-
var passed = 0;
|
21
|
-
var failed = 0;
|
22
|
-
|
23
|
-
if (!this["output"]) {
|
24
|
-
var output = function (string) {
|
25
|
-
return doc ? doc.write(string + '<br/>') : console.log(string);
|
26
|
-
};
|
27
|
-
}
|
28
|
-
|
29
|
-
function runTest(tests) {
|
30
|
-
tests.forEach(function(test) {
|
31
|
-
var partials = {};
|
32
|
-
for (var i in test.partials) {
|
33
|
-
partials[i] = Hogan.compile(test.partials[i]);
|
34
|
-
}
|
35
|
-
var t = Hogan.compile(test.template);
|
36
|
-
|
37
|
-
if (test.data.lambda) {
|
38
|
-
var func = (new Function ('return ' + test.data.lambda.js)());
|
39
|
-
test.data.lambda = function() { return func; };
|
40
|
-
}
|
41
|
-
|
42
|
-
var s = t.render(test.data, partials);
|
43
|
-
is(s, test.expected, test.name + ': ' + test.desc);
|
44
|
-
});
|
45
|
-
}
|
46
|
-
|
47
|
-
var testDir = './test/spec/specs';
|
48
|
-
var files = fs.readdirSync(testDir)
|
49
|
-
.filter(function(f) { return f.indexOf('.json') > 0; })
|
50
|
-
.map(function(f) { return testDir + '/' + f});
|
51
|
-
|
52
|
-
for (var i = 0; i < files.length; i++) {
|
53
|
-
var test = JSON.parse(fs.readFileSync(files[i]).toString());
|
54
|
-
runTest(test.tests);
|
55
|
-
}
|
56
|
-
|
57
|
-
function is(got, expected, msg) {
|
58
|
-
if (got === expected) {
|
59
|
-
output("OK: " + msg);
|
60
|
-
++passed;
|
61
|
-
} else {
|
62
|
-
output("FAIL: " + msg);
|
63
|
-
output("Expected |" + expected + "|");
|
64
|
-
output(" Got |" + got + "|");
|
65
|
-
++failed;
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
function complete() {
|
70
|
-
output("\nTests Complete");
|
71
|
-
output("--------------");
|
72
|
-
output("Passed: " + passed);
|
73
|
-
output("Failed: " + failed);
|
74
|
-
output("\n");
|
75
|
-
}
|
76
|
-
|
77
|
-
complete();
|
@@ -1,233 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
var Hogan = {};
|
17
|
-
|
18
|
-
(function (Hogan) {
|
19
|
-
Hogan.Template = function constructor(renderFunc, text, compiler) {
|
20
|
-
if (renderFunc) {
|
21
|
-
this.r = renderFunc;
|
22
|
-
}
|
23
|
-
this.c = compiler;
|
24
|
-
this.text = text || '';
|
25
|
-
}
|
26
|
-
|
27
|
-
Hogan.Template.prototype = {
|
28
|
-
// render: replaced by generated code.
|
29
|
-
r: function (context, partials, indent) { return ''; },
|
30
|
-
|
31
|
-
// variable escaping
|
32
|
-
v: hoganEscape,
|
33
|
-
|
34
|
-
render: function render(context, partials, indent) {
|
35
|
-
return this.ri([context], partials || {}, indent);
|
36
|
-
},
|
37
|
-
|
38
|
-
// render internal -- a hook for overrides that catches partials too
|
39
|
-
ri: function (context, partials, indent) {
|
40
|
-
return this.r(context, partials, indent);
|
41
|
-
},
|
42
|
-
|
43
|
-
// tries to find a partial in the curent scope and render it
|
44
|
-
rp: function(name, context, partials, indent) {
|
45
|
-
var partial = partials[name];
|
46
|
-
|
47
|
-
if (!partial) {
|
48
|
-
return '';
|
49
|
-
}
|
50
|
-
|
51
|
-
if (this.c && typeof partial == 'string') {
|
52
|
-
partial = this.c.compile(partial);
|
53
|
-
}
|
54
|
-
|
55
|
-
return partial.ri(context, partials, indent);
|
56
|
-
},
|
57
|
-
|
58
|
-
// render a section
|
59
|
-
rs: function(context, partials, section) {
|
60
|
-
var buf = '',
|
61
|
-
tail = context[context.length - 1];
|
62
|
-
|
63
|
-
if (!isArray(tail)) {
|
64
|
-
return buf = section(context, partials);
|
65
|
-
}
|
66
|
-
|
67
|
-
for (var i = 0; i < tail.length; i++) {
|
68
|
-
context.push(tail[i]);
|
69
|
-
buf += section(context, partials);
|
70
|
-
context.pop();
|
71
|
-
}
|
72
|
-
|
73
|
-
return buf;
|
74
|
-
},
|
75
|
-
|
76
|
-
// maybe start a section
|
77
|
-
s: function(val, ctx, partials, inverted, start, end, tags) {
|
78
|
-
var pass;
|
79
|
-
|
80
|
-
if (isArray(val) && val.length === 0) {
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
|
84
|
-
if (typeof val == 'function') {
|
85
|
-
val = this.ls(val, ctx, partials, inverted, start, end, tags);
|
86
|
-
}
|
87
|
-
|
88
|
-
pass = (val === '') || !!val;
|
89
|
-
|
90
|
-
if (!inverted && pass && ctx) {
|
91
|
-
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
|
92
|
-
}
|
93
|
-
|
94
|
-
return pass;
|
95
|
-
},
|
96
|
-
|
97
|
-
// find values with dotted names
|
98
|
-
d: function(key, ctx, partials, returnFound) {
|
99
|
-
var names = key.split('.'),
|
100
|
-
val = this.f(names[0], ctx, partials, returnFound),
|
101
|
-
cx = null;
|
102
|
-
|
103
|
-
if (key === '.' && isArray(ctx[ctx.length - 2])) {
|
104
|
-
return ctx[ctx.length - 1];
|
105
|
-
}
|
106
|
-
|
107
|
-
for (var i = 1; i < names.length; i++) {
|
108
|
-
if (val && typeof val == 'object' && names[i] in val) {
|
109
|
-
cx = val;
|
110
|
-
val = val[names[i]];
|
111
|
-
} else {
|
112
|
-
val = '';
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
if (returnFound && !val) {
|
117
|
-
return false;
|
118
|
-
}
|
119
|
-
|
120
|
-
if (!returnFound && typeof val == 'function') {
|
121
|
-
ctx.push(cx);
|
122
|
-
val = this.lv(val, ctx, partials);
|
123
|
-
ctx.pop();
|
124
|
-
}
|
125
|
-
|
126
|
-
return val;
|
127
|
-
},
|
128
|
-
|
129
|
-
// find values with normal names
|
130
|
-
f: function(key, ctx, partials, returnFound) {
|
131
|
-
var val = false,
|
132
|
-
v = null,
|
133
|
-
found = false;
|
134
|
-
|
135
|
-
for (var i = ctx.length - 1; i >= 0; i--) {
|
136
|
-
v = ctx[i];
|
137
|
-
if (v && typeof v == 'object' && key in v) {
|
138
|
-
val = v[key];
|
139
|
-
found = true;
|
140
|
-
break;
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
if (!found) {
|
145
|
-
return (returnFound) ? false : "";
|
146
|
-
}
|
147
|
-
|
148
|
-
if (!returnFound && typeof val == 'function') {
|
149
|
-
val = this.lv(val, ctx, partials);
|
150
|
-
}
|
151
|
-
|
152
|
-
return val;
|
153
|
-
},
|
154
|
-
|
155
|
-
// higher order templates
|
156
|
-
ho: function(val, cx, partials, text, tags) {
|
157
|
-
var compiler = this.c;
|
158
|
-
var t = val.call(cx, text, function(t) {
|
159
|
-
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
|
160
|
-
});
|
161
|
-
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
|
162
|
-
this.b = s;
|
163
|
-
return false;
|
164
|
-
},
|
165
|
-
|
166
|
-
// higher order template result buffer
|
167
|
-
b: '',
|
168
|
-
|
169
|
-
// lambda replace section
|
170
|
-
ls: function(val, ctx, partials, inverted, start, end, tags) {
|
171
|
-
var cx = ctx[ctx.length - 1],
|
172
|
-
t = null;
|
173
|
-
|
174
|
-
if (!inverted && this.c && val.length > 0) {
|
175
|
-
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
|
176
|
-
}
|
177
|
-
|
178
|
-
t = val.call(cx);
|
179
|
-
|
180
|
-
if (typeof t == 'function') {
|
181
|
-
if (inverted) {
|
182
|
-
return true;
|
183
|
-
} else if (this.c) {
|
184
|
-
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
return t;
|
189
|
-
},
|
190
|
-
|
191
|
-
// lambda replace variable
|
192
|
-
lv: function(val, ctx, partials) {
|
193
|
-
var cx = ctx[ctx.length - 1];
|
194
|
-
var result = val.call(cx);
|
195
|
-
if (typeof result == 'function') {
|
196
|
-
result = result.call(cx);
|
197
|
-
}
|
198
|
-
result = result.toString();
|
199
|
-
|
200
|
-
if (this.c && ~result.indexOf("{{")) {
|
201
|
-
return this.c.compile(result).render(cx, partials);
|
202
|
-
}
|
203
|
-
|
204
|
-
return result;
|
205
|
-
}
|
206
|
-
|
207
|
-
};
|
208
|
-
|
209
|
-
var rAmp = /&/g,
|
210
|
-
rLt = /</g,
|
211
|
-
rGt = />/g,
|
212
|
-
rApos =/\'/g,
|
213
|
-
rQuot = /\"/g,
|
214
|
-
hChars =/[&<>\"\']/;
|
215
|
-
|
216
|
-
function hoganEscape(str) {
|
217
|
-
str = String((str === null || str === undefined) ? '' : str);
|
218
|
-
return hChars.test(str) ?
|
219
|
-
str
|
220
|
-
.replace(rAmp,'&')
|
221
|
-
.replace(rLt,'<')
|
222
|
-
.replace(rGt,'>')
|
223
|
-
.replace(rApos,''')
|
224
|
-
.replace(rQuot, '"') :
|
225
|
-
str;
|
226
|
-
}
|
227
|
-
|
228
|
-
var isArray = Array.isArray || function(a) {
|
229
|
-
return Object.prototype.toString.call(a) === '[object Array]';
|
230
|
-
};
|
231
|
-
|
232
|
-
})(typeof exports !== 'undefined' ? exports : Hogan);
|
233
|
-
|
@@ -1,233 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2011 Twitter, Inc.
|
3
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
* you may not use this file except in compliance with the License.
|
5
|
-
* You may obtain a copy of the License at
|
6
|
-
*
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
*
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
* See the License for the specific language governing permissions and
|
13
|
-
* limitations under the License.
|
14
|
-
*/
|
15
|
-
|
16
|
-
var Hogan = {};
|
17
|
-
|
18
|
-
(function (Hogan) {
|
19
|
-
Hogan.Template = function constructor(renderFunc, text, compiler) {
|
20
|
-
if (renderFunc) {
|
21
|
-
this.r = renderFunc;
|
22
|
-
}
|
23
|
-
this.c = compiler;
|
24
|
-
this.text = text || '';
|
25
|
-
}
|
26
|
-
|
27
|
-
Hogan.Template.prototype = {
|
28
|
-
// render: replaced by generated code.
|
29
|
-
r: function (context, partials, indent) { return ''; },
|
30
|
-
|
31
|
-
// variable escaping
|
32
|
-
v: hoganEscape,
|
33
|
-
|
34
|
-
render: function render(context, partials, indent) {
|
35
|
-
return this.ri([context], partials || {}, indent);
|
36
|
-
},
|
37
|
-
|
38
|
-
// render internal -- a hook for overrides that catches partials too
|
39
|
-
ri: function (context, partials, indent) {
|
40
|
-
return this.r(context, partials, indent);
|
41
|
-
},
|
42
|
-
|
43
|
-
// tries to find a partial in the curent scope and render it
|
44
|
-
rp: function(name, context, partials, indent) {
|
45
|
-
var partial = partials[name];
|
46
|
-
|
47
|
-
if (!partial) {
|
48
|
-
return '';
|
49
|
-
}
|
50
|
-
|
51
|
-
if (this.c && typeof partial == 'string') {
|
52
|
-
partial = this.c.compile(partial);
|
53
|
-
}
|
54
|
-
|
55
|
-
return partial.ri(context, partials, indent);
|
56
|
-
},
|
57
|
-
|
58
|
-
// render a section
|
59
|
-
rs: function(context, partials, section) {
|
60
|
-
var buf = '',
|
61
|
-
tail = context[context.length - 1];
|
62
|
-
|
63
|
-
if (!isArray(tail)) {
|
64
|
-
return buf = section(context, partials);
|
65
|
-
}
|
66
|
-
|
67
|
-
for (var i = 0; i < tail.length; i++) {
|
68
|
-
context.push(tail[i]);
|
69
|
-
buf += section(context, partials);
|
70
|
-
context.pop();
|
71
|
-
}
|
72
|
-
|
73
|
-
return buf;
|
74
|
-
},
|
75
|
-
|
76
|
-
// maybe start a section
|
77
|
-
s: function(val, ctx, partials, inverted, start, end, tags) {
|
78
|
-
var pass;
|
79
|
-
|
80
|
-
if (isArray(val) && val.length === 0) {
|
81
|
-
return false;
|
82
|
-
}
|
83
|
-
|
84
|
-
if (typeof val == 'function') {
|
85
|
-
val = this.ls(val, ctx, partials, inverted, start, end, tags);
|
86
|
-
}
|
87
|
-
|
88
|
-
pass = (val === '') || !!val;
|
89
|
-
|
90
|
-
if (!inverted && pass && ctx) {
|
91
|
-
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
|
92
|
-
}
|
93
|
-
|
94
|
-
return pass;
|
95
|
-
},
|
96
|
-
|
97
|
-
// find values with dotted names
|
98
|
-
d: function(key, ctx, partials, returnFound) {
|
99
|
-
var names = key.split('.'),
|
100
|
-
val = this.f(names[0], ctx, partials, returnFound),
|
101
|
-
cx = null;
|
102
|
-
|
103
|
-
if (key === '.' && isArray(ctx[ctx.length - 2])) {
|
104
|
-
return ctx[ctx.length - 1];
|
105
|
-
}
|
106
|
-
|
107
|
-
for (var i = 1; i < names.length; i++) {
|
108
|
-
if (val && typeof val == 'object' && names[i] in val) {
|
109
|
-
cx = val;
|
110
|
-
val = val[names[i]];
|
111
|
-
} else {
|
112
|
-
val = '';
|
113
|
-
}
|
114
|
-
}
|
115
|
-
|
116
|
-
if (returnFound && !val) {
|
117
|
-
return false;
|
118
|
-
}
|
119
|
-
|
120
|
-
if (!returnFound && typeof val == 'function') {
|
121
|
-
ctx.push(cx);
|
122
|
-
val = this.lv(val, ctx, partials);
|
123
|
-
ctx.pop();
|
124
|
-
}
|
125
|
-
|
126
|
-
return val;
|
127
|
-
},
|
128
|
-
|
129
|
-
// find values with normal names
|
130
|
-
f: function(key, ctx, partials, returnFound) {
|
131
|
-
var val = false,
|
132
|
-
v = null,
|
133
|
-
found = false;
|
134
|
-
|
135
|
-
for (var i = ctx.length - 1; i >= 0; i--) {
|
136
|
-
v = ctx[i];
|
137
|
-
if (v && typeof v == 'object' && key in v) {
|
138
|
-
val = v[key];
|
139
|
-
found = true;
|
140
|
-
break;
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
if (!found) {
|
145
|
-
return (returnFound) ? false : "";
|
146
|
-
}
|
147
|
-
|
148
|
-
if (!returnFound && typeof val == 'function') {
|
149
|
-
val = this.lv(val, ctx, partials);
|
150
|
-
}
|
151
|
-
|
152
|
-
return val;
|
153
|
-
},
|
154
|
-
|
155
|
-
// higher order templates
|
156
|
-
ho: function(val, cx, partials, text, tags) {
|
157
|
-
var compiler = this.c;
|
158
|
-
var t = val.call(cx, text, function(t) {
|
159
|
-
return compiler.compile(t, {delimiters: tags}).render(cx, partials);
|
160
|
-
});
|
161
|
-
var s = compiler.compile(t.toString(), {delimiters: tags}).render(cx, partials);
|
162
|
-
this.b = s;
|
163
|
-
return false;
|
164
|
-
},
|
165
|
-
|
166
|
-
// higher order template result buffer
|
167
|
-
b: '',
|
168
|
-
|
169
|
-
// lambda replace section
|
170
|
-
ls: function(val, ctx, partials, inverted, start, end, tags) {
|
171
|
-
var cx = ctx[ctx.length - 1],
|
172
|
-
t = null;
|
173
|
-
|
174
|
-
if (!inverted && this.c && val.length > 0) {
|
175
|
-
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
|
176
|
-
}
|
177
|
-
|
178
|
-
t = val.call(cx);
|
179
|
-
|
180
|
-
if (typeof t == 'function') {
|
181
|
-
if (inverted) {
|
182
|
-
return true;
|
183
|
-
} else if (this.c) {
|
184
|
-
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
return t;
|
189
|
-
},
|
190
|
-
|
191
|
-
// lambda replace variable
|
192
|
-
lv: function(val, ctx, partials) {
|
193
|
-
var cx = ctx[ctx.length - 1];
|
194
|
-
var result = val.call(cx);
|
195
|
-
if (typeof result == 'function') {
|
196
|
-
result = result.call(cx);
|
197
|
-
}
|
198
|
-
result = result.toString();
|
199
|
-
|
200
|
-
if (this.c && ~result.indexOf("{{")) {
|
201
|
-
return this.c.compile(result).render(cx, partials);
|
202
|
-
}
|
203
|
-
|
204
|
-
return result;
|
205
|
-
}
|
206
|
-
|
207
|
-
};
|
208
|
-
|
209
|
-
var rAmp = /&/g,
|
210
|
-
rLt = /</g,
|
211
|
-
rGt = />/g,
|
212
|
-
rApos =/\'/g,
|
213
|
-
rQuot = /\"/g,
|
214
|
-
hChars =/[&<>\"\']/;
|
215
|
-
|
216
|
-
function hoganEscape(str) {
|
217
|
-
str = String((str === null || str === undefined) ? '' : str);
|
218
|
-
return hChars.test(str) ?
|
219
|
-
str
|
220
|
-
.replace(rAmp,'&')
|
221
|
-
.replace(rLt,'<')
|
222
|
-
.replace(rGt,'>')
|
223
|
-
.replace(rApos,''')
|
224
|
-
.replace(rQuot, '"') :
|
225
|
-
str;
|
226
|
-
}
|
227
|
-
|
228
|
-
var isArray = Array.isArray || function(a) {
|
229
|
-
return Object.prototype.toString.call(a) === '[object Array]';
|
230
|
-
};
|
231
|
-
|
232
|
-
})(typeof exports !== 'undefined' ? exports : Hogan);
|
233
|
-
|