pullentity-client 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/CHANGELOG.md +2 -0
- data/README.md +1 -1
- data/lib/pullentity-client/cli.rb +1 -1
- data/lib/pullentity-client/generate/auth.rb +32 -18
- data/lib/pullentity-client/generate/exporter.rb +14 -2
- data/lib/pullentity-client/generate/theme.rb +3 -3
- data/lib/pullentity-client/templates/app/assets/javascripts/application.js.erb +2 -1
- data/lib/pullentity-client/templates/app/assets/javascripts/config.js.erb +6 -0
- data/lib/pullentity-client/templates/app/assets/stylesheets/customtheme.css.scss +14 -8
- data/lib/pullentity-client/templates/app/index.html.haml +5 -3
- data/lib/pullentity-client/templates/app/views/list.haml +6 -6
- data/lib/pullentity-client/templates/app/views/shared/body.haml +5 -5
- data/lib/pullentity-client/templates/app/views/shared/head.haml +1 -9
- data/lib/pullentity-client/templates/app/views/shared/js.haml +0 -3
- data/lib/pullentity-client/templates/app/views/themes/home.haml +0 -1
- data/lib/pullentity-client/templates/app/views/themes/list-2.haml +13 -0
- data/lib/pullentity-client/templates/app/views/themes/theme1.haml +7 -8
- data/lib/pullentity-client/version.rb +1 -1
- data/spec/pullentity-client/generate/exporter_spec.rb +3 -3
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/javascripts/{pullentity → backbone}/.DS_Store +0 -0
- data/vendor/assets/javascripts/backbone/backbone.js +1571 -0
- data/vendor/assets/javascripts/backbone/underscore.js +1227 -0
- data/vendor/assets/javascripts/bootstrap.js +1964 -0
- data/vendor/assets/javascripts/bootstrap.min.js +6 -0
- data/vendor/assets/javascripts/galleria/LICENSE +21 -0
- data/vendor/assets/javascripts/galleria/galleria-1.2.9.js +6121 -0
- data/vendor/assets/javascripts/galleria/galleria-1.2.9.min.js +9 -0
- data/vendor/assets/javascripts/galleria/plugins/flickr/flickr-demo.html +62 -0
- data/vendor/assets/javascripts/galleria/plugins/flickr/flickr-loader.gif +0 -0
- data/vendor/assets/javascripts/galleria/plugins/flickr/galleria.flickr.js +383 -0
- data/vendor/assets/javascripts/galleria/plugins/flickr/galleria.flickr.min.js +8 -0
- data/vendor/assets/javascripts/galleria/plugins/flickr/loader.gif +0 -0
- data/vendor/assets/javascripts/galleria/plugins/history/galleria.history.js +146 -0
- data/vendor/assets/javascripts/galleria/plugins/history/galleria.history.min.js +8 -0
- data/vendor/assets/javascripts/galleria/plugins/history/history-demo.html +100 -0
- data/vendor/assets/javascripts/galleria/plugins/picasa/galleria.picasa.js +320 -0
- data/vendor/assets/javascripts/galleria/plugins/picasa/galleria.picasa.min.js +8 -0
- data/vendor/assets/javascripts/galleria/plugins/picasa/loader.gif +0 -0
- data/vendor/assets/javascripts/galleria/plugins/picasa/picasa-demo.html +55 -0
- data/vendor/assets/javascripts/galleria/themes/classic/classic-demo.html +124 -0
- data/vendor/assets/javascripts/galleria/themes/classic/classic-loader.gif +0 -0
- data/vendor/assets/javascripts/galleria/themes/classic/classic-map.png +0 -0
- data/vendor/assets/javascripts/galleria/themes/classic/galleria.classic.css +220 -0
- data/vendor/assets/javascripts/galleria/themes/classic/galleria.classic.js +95 -0
- data/vendor/assets/javascripts/galleria/themes/classic/galleria.classic.min.js +8 -0
- data/vendor/assets/javascripts/handlebars.js +2278 -0
- data/vendor/assets/javascripts/jquery.infinite-scroll.min.js +1 -0
- data/vendor/assets/javascripts/jquery.isotope.min.js +11 -0
- data/vendor/assets/javascripts/jquery.loadimage.js +3 -0
- data/vendor/assets/javascripts/jquery.masonry.min.js +10 -0
- data/vendor/assets/javascripts/jquery.waitforimages.js +4 -0
- data/vendor/assets/javascripts/pullentity-backbone/.DS_Store +0 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/helpers/app_helper.js.coffee +12 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/project.js.coffee +11 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/section.js.coffee +13 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/models/site.js.coffee +7 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/routers/router.coffee +7 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/site.js.coffee +33 -0
- data/vendor/assets/javascripts/pullentity-backbone/app/views/main.js.coffee +123 -0
- data/vendor/assets/javascripts/pullentity-backbone/application.js.coffee +8 -0
- data/vendor/assets/javascripts/pullentity.js +3 -0
- data/vendor/assets/stylesheets/bootstrap.css +4677 -0
- data/vendor/assets/stylesheets/bootstrap.min.css +9 -0
- data/vendor/assets/stylesheets/galleria/LICENSE +21 -0
- data/vendor/assets/stylesheets/galleria/galleria-1.2.9.js +6121 -0
- data/vendor/assets/stylesheets/galleria/galleria-1.2.9.min.js +9 -0
- data/vendor/assets/stylesheets/galleria/plugins/flickr/flickr-demo.html +62 -0
- data/vendor/assets/stylesheets/galleria/plugins/flickr/flickr-loader.gif +0 -0
- data/vendor/assets/stylesheets/galleria/plugins/flickr/galleria.flickr.js +383 -0
- data/vendor/assets/stylesheets/galleria/plugins/flickr/galleria.flickr.min.js +8 -0
- data/vendor/assets/stylesheets/galleria/plugins/flickr/loader.gif +0 -0
- data/vendor/assets/stylesheets/galleria/plugins/history/galleria.history.js +146 -0
- data/vendor/assets/stylesheets/galleria/plugins/history/galleria.history.min.js +8 -0
- data/vendor/assets/stylesheets/galleria/plugins/history/history-demo.html +100 -0
- data/vendor/assets/stylesheets/galleria/plugins/picasa/galleria.picasa.js +320 -0
- data/vendor/assets/stylesheets/galleria/plugins/picasa/galleria.picasa.min.js +8 -0
- data/vendor/assets/stylesheets/galleria/plugins/picasa/loader.gif +0 -0
- data/vendor/assets/stylesheets/galleria/plugins/picasa/picasa-demo.html +55 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/classic-demo.html +124 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/classic-loader.gif +0 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/classic-map-original.png +0 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/galleria.classic.css +217 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/galleria.classic.js +95 -0
- data/vendor/assets/stylesheets/galleria/themes/classic/galleria.classic.min.js +8 -0
- metadata +70 -8
- data/lib/pullentity-client/templates/defaults/test-data.js.erb +0 -193
- data/vendor/assets/javascripts/mustache.js +0 -535
- data/vendor/assets/javascripts/pullentity/development.js.coffee +0 -222
- data/vendor/assets/javascripts/pullentity.js.erb +0 -3
- data/vendor/assets/javascripts/underscore-min.js +0 -1
@@ -1,535 +0,0 @@
|
|
1
|
-
/*!
|
2
|
-
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
3
|
-
* http://github.com/janl/mustache.js
|
4
|
-
*/
|
5
|
-
|
6
|
-
/*global define: false*/
|
7
|
-
|
8
|
-
(function (root, factory) {
|
9
|
-
if (typeof exports === "object" && exports) {
|
10
|
-
module.exports = factory; // CommonJS
|
11
|
-
} else if (typeof define === "function" && define.amd) {
|
12
|
-
define(factory); // AMD
|
13
|
-
} else {
|
14
|
-
root.Mustache = factory; // <script>
|
15
|
-
}
|
16
|
-
}(this, (function () {
|
17
|
-
|
18
|
-
var exports = {};
|
19
|
-
|
20
|
-
exports.name = "mustache.js";
|
21
|
-
exports.version = "0.7.2";
|
22
|
-
exports.tags = ["{{", "}}"];
|
23
|
-
|
24
|
-
exports.Scanner = Scanner;
|
25
|
-
exports.Context = Context;
|
26
|
-
exports.Writer = Writer;
|
27
|
-
|
28
|
-
var whiteRe = /\s*/;
|
29
|
-
var spaceRe = /\s+/;
|
30
|
-
var nonSpaceRe = /\S/;
|
31
|
-
var eqRe = /\s*=/;
|
32
|
-
var curlyRe = /\s*\}/;
|
33
|
-
var tagRe = /#|\^|\/|>|\{|&|=|!/;
|
34
|
-
|
35
|
-
var _test = RegExp.prototype.test;
|
36
|
-
var _toString = Object.prototype.toString;
|
37
|
-
|
38
|
-
// Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
|
39
|
-
// See https://github.com/janl/mustache.js/issues/189
|
40
|
-
function testRe(re, string) {
|
41
|
-
return _test.call(re, string);
|
42
|
-
}
|
43
|
-
|
44
|
-
function isWhitespace(string) {
|
45
|
-
return !testRe(nonSpaceRe, string);
|
46
|
-
}
|
47
|
-
|
48
|
-
var isArray = Array.isArray || function (obj) {
|
49
|
-
return _toString.call(obj) === '[object Array]';
|
50
|
-
};
|
51
|
-
|
52
|
-
function escapeRe(string) {
|
53
|
-
return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
54
|
-
}
|
55
|
-
|
56
|
-
var entityMap = {
|
57
|
-
"&": "&",
|
58
|
-
"<": "<",
|
59
|
-
">": ">",
|
60
|
-
'"': '"',
|
61
|
-
"'": ''',
|
62
|
-
"/": '/'
|
63
|
-
};
|
64
|
-
|
65
|
-
function escapeHtml(string) {
|
66
|
-
return String(string).replace(/[&<>"'\/]/g, function (s) {
|
67
|
-
return entityMap[s];
|
68
|
-
});
|
69
|
-
}
|
70
|
-
|
71
|
-
// Export the escaping function so that the user may override it.
|
72
|
-
// See https://github.com/janl/mustache.js/issues/244
|
73
|
-
exports.escape = escapeHtml;
|
74
|
-
|
75
|
-
function Scanner(string) {
|
76
|
-
this.string = string;
|
77
|
-
this.tail = string;
|
78
|
-
this.pos = 0;
|
79
|
-
}
|
80
|
-
|
81
|
-
/**
|
82
|
-
* Returns `true` if the tail is empty (end of string).
|
83
|
-
*/
|
84
|
-
Scanner.prototype.eos = function () {
|
85
|
-
return this.tail === "";
|
86
|
-
};
|
87
|
-
|
88
|
-
/**
|
89
|
-
* Tries to match the given regular expression at the current position.
|
90
|
-
* Returns the matched text if it can match, the empty string otherwise.
|
91
|
-
*/
|
92
|
-
Scanner.prototype.scan = function (re) {
|
93
|
-
var match = this.tail.match(re);
|
94
|
-
|
95
|
-
if (match && match.index === 0) {
|
96
|
-
this.tail = this.tail.substring(match[0].length);
|
97
|
-
this.pos += match[0].length;
|
98
|
-
return match[0];
|
99
|
-
}
|
100
|
-
|
101
|
-
return "";
|
102
|
-
};
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Skips all text until the given regular expression can be matched. Returns
|
106
|
-
* the skipped string, which is the entire tail if no match can be made.
|
107
|
-
*/
|
108
|
-
Scanner.prototype.scanUntil = function (re) {
|
109
|
-
var match, pos = this.tail.search(re);
|
110
|
-
|
111
|
-
switch (pos) {
|
112
|
-
case -1:
|
113
|
-
match = this.tail;
|
114
|
-
this.pos += this.tail.length;
|
115
|
-
this.tail = "";
|
116
|
-
break;
|
117
|
-
case 0:
|
118
|
-
match = "";
|
119
|
-
break;
|
120
|
-
default:
|
121
|
-
match = this.tail.substring(0, pos);
|
122
|
-
this.tail = this.tail.substring(pos);
|
123
|
-
this.pos += pos;
|
124
|
-
}
|
125
|
-
|
126
|
-
return match;
|
127
|
-
};
|
128
|
-
|
129
|
-
function Context(view, parent) {
|
130
|
-
this.view = view;
|
131
|
-
this.parent = parent;
|
132
|
-
this._cache = {};
|
133
|
-
}
|
134
|
-
|
135
|
-
Context.make = function (view) {
|
136
|
-
return (view instanceof Context) ? view : new Context(view);
|
137
|
-
};
|
138
|
-
|
139
|
-
Context.prototype.push = function (view) {
|
140
|
-
return new Context(view, this);
|
141
|
-
};
|
142
|
-
|
143
|
-
Context.prototype.lookup = function (name) {
|
144
|
-
var value = this._cache[name];
|
145
|
-
|
146
|
-
if (!value) {
|
147
|
-
if (name == '.') {
|
148
|
-
value = this.view;
|
149
|
-
} else {
|
150
|
-
var context = this;
|
151
|
-
|
152
|
-
while (context) {
|
153
|
-
if (name.indexOf('.') > 0) {
|
154
|
-
value = context.view;
|
155
|
-
var names = name.split('.'), i = 0;
|
156
|
-
while (value && i < names.length) {
|
157
|
-
value = value[names[i++]];
|
158
|
-
}
|
159
|
-
} else {
|
160
|
-
value = context.view[name];
|
161
|
-
}
|
162
|
-
|
163
|
-
if (value != null) break;
|
164
|
-
|
165
|
-
context = context.parent;
|
166
|
-
}
|
167
|
-
}
|
168
|
-
|
169
|
-
this._cache[name] = value;
|
170
|
-
}
|
171
|
-
|
172
|
-
if (typeof value === 'function') value = value.call(this.view);
|
173
|
-
|
174
|
-
return value;
|
175
|
-
};
|
176
|
-
|
177
|
-
function Writer() {
|
178
|
-
this.clearCache();
|
179
|
-
}
|
180
|
-
|
181
|
-
Writer.prototype.clearCache = function () {
|
182
|
-
this._cache = {};
|
183
|
-
this._partialCache = {};
|
184
|
-
};
|
185
|
-
|
186
|
-
Writer.prototype.compile = function (template, tags) {
|
187
|
-
var fn = this._cache[template];
|
188
|
-
|
189
|
-
if (!fn) {
|
190
|
-
var tokens = exports.parse(template, tags);
|
191
|
-
fn = this._cache[template] = this.compileTokens(tokens, template);
|
192
|
-
}
|
193
|
-
|
194
|
-
return fn;
|
195
|
-
};
|
196
|
-
|
197
|
-
Writer.prototype.compilePartial = function (name, template, tags) {
|
198
|
-
var fn = this.compile(template, tags);
|
199
|
-
this._partialCache[name] = fn;
|
200
|
-
return fn;
|
201
|
-
};
|
202
|
-
|
203
|
-
Writer.prototype.getPartial = function (name) {
|
204
|
-
if (!(name in this._partialCache) && this._loadPartial) {
|
205
|
-
this.compilePartial(name, this._loadPartial(name));
|
206
|
-
}
|
207
|
-
|
208
|
-
return this._partialCache[name];
|
209
|
-
};
|
210
|
-
|
211
|
-
Writer.prototype.compileTokens = function (tokens, template) {
|
212
|
-
var self = this;
|
213
|
-
return function (view, partials) {
|
214
|
-
if (partials) {
|
215
|
-
if (typeof partials === 'function') {
|
216
|
-
self._loadPartial = partials;
|
217
|
-
} else {
|
218
|
-
for (var name in partials) {
|
219
|
-
self.compilePartial(name, partials[name]);
|
220
|
-
}
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
return renderTokens(tokens, self, Context.make(view), template);
|
225
|
-
};
|
226
|
-
};
|
227
|
-
|
228
|
-
Writer.prototype.render = function (template, view, partials) {
|
229
|
-
return this.compile(template)(view, partials);
|
230
|
-
};
|
231
|
-
|
232
|
-
/**
|
233
|
-
* Low-level function that renders the given `tokens` using the given `writer`
|
234
|
-
* and `context`. The `template` string is only needed for templates that use
|
235
|
-
* higher-order sections to extract the portion of the original template that
|
236
|
-
* was contained in that section.
|
237
|
-
*/
|
238
|
-
function renderTokens(tokens, writer, context, template) {
|
239
|
-
var buffer = '';
|
240
|
-
|
241
|
-
var token, tokenValue, value;
|
242
|
-
for (var i = 0, len = tokens.length; i < len; ++i) {
|
243
|
-
token = tokens[i];
|
244
|
-
tokenValue = token[1];
|
245
|
-
|
246
|
-
switch (token[0]) {
|
247
|
-
case '#':
|
248
|
-
value = context.lookup(tokenValue);
|
249
|
-
|
250
|
-
if (typeof value === 'object') {
|
251
|
-
if (isArray(value)) {
|
252
|
-
for (var j = 0, jlen = value.length; j < jlen; ++j) {
|
253
|
-
buffer += renderTokens(token[4], writer, context.push(value[j]), template);
|
254
|
-
}
|
255
|
-
} else if (value) {
|
256
|
-
buffer += renderTokens(token[4], writer, context.push(value), template);
|
257
|
-
}
|
258
|
-
} else if (typeof value === 'function') {
|
259
|
-
var text = template == null ? null : template.slice(token[3], token[5]);
|
260
|
-
value = value.call(context.view, text, function (template) {
|
261
|
-
return writer.render(template, context);
|
262
|
-
});
|
263
|
-
if (value != null) buffer += value;
|
264
|
-
} else if (value) {
|
265
|
-
buffer += renderTokens(token[4], writer, context, template);
|
266
|
-
}
|
267
|
-
|
268
|
-
break;
|
269
|
-
case '^':
|
270
|
-
value = context.lookup(tokenValue);
|
271
|
-
|
272
|
-
// Use JavaScript's definition of falsy. Include empty arrays.
|
273
|
-
// See https://github.com/janl/mustache.js/issues/186
|
274
|
-
if (!value || (isArray(value) && value.length === 0)) {
|
275
|
-
buffer += renderTokens(token[4], writer, context, template);
|
276
|
-
}
|
277
|
-
|
278
|
-
break;
|
279
|
-
case '>':
|
280
|
-
value = writer.getPartial(tokenValue);
|
281
|
-
if (typeof value === 'function') buffer += value(context);
|
282
|
-
break;
|
283
|
-
case '&':
|
284
|
-
value = context.lookup(tokenValue);
|
285
|
-
if (value != null) buffer += value;
|
286
|
-
break;
|
287
|
-
case 'name':
|
288
|
-
value = context.lookup(tokenValue);
|
289
|
-
if (value != null) buffer += exports.escape(value);
|
290
|
-
break;
|
291
|
-
case 'text':
|
292
|
-
buffer += tokenValue;
|
293
|
-
break;
|
294
|
-
}
|
295
|
-
}
|
296
|
-
|
297
|
-
return buffer;
|
298
|
-
}
|
299
|
-
|
300
|
-
/**
|
301
|
-
* Forms the given array of `tokens` into a nested tree structure where
|
302
|
-
* tokens that represent a section have two additional items: 1) an array of
|
303
|
-
* all tokens that appear in that section and 2) the index in the original
|
304
|
-
* template that represents the end of that section.
|
305
|
-
*/
|
306
|
-
function nestTokens(tokens) {
|
307
|
-
var tree = [];
|
308
|
-
var collector = tree;
|
309
|
-
var sections = [];
|
310
|
-
|
311
|
-
var token;
|
312
|
-
for (var i = 0, len = tokens.length; i < len; ++i) {
|
313
|
-
token = tokens[i];
|
314
|
-
switch (token[0]) {
|
315
|
-
case '#':
|
316
|
-
case '^':
|
317
|
-
sections.push(token);
|
318
|
-
collector.push(token);
|
319
|
-
collector = token[4] = [];
|
320
|
-
break;
|
321
|
-
case '/':
|
322
|
-
var section = sections.pop();
|
323
|
-
section[5] = token[2];
|
324
|
-
collector = sections.length > 0 ? sections[sections.length - 1][4] : tree;
|
325
|
-
break;
|
326
|
-
default:
|
327
|
-
collector.push(token);
|
328
|
-
}
|
329
|
-
}
|
330
|
-
|
331
|
-
return tree;
|
332
|
-
}
|
333
|
-
|
334
|
-
/**
|
335
|
-
* Combines the values of consecutive text tokens in the given `tokens` array
|
336
|
-
* to a single token.
|
337
|
-
*/
|
338
|
-
function squashTokens(tokens) {
|
339
|
-
var squashedTokens = [];
|
340
|
-
|
341
|
-
var token, lastToken;
|
342
|
-
for (var i = 0, len = tokens.length; i < len; ++i) {
|
343
|
-
token = tokens[i];
|
344
|
-
if (token) {
|
345
|
-
if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
|
346
|
-
lastToken[1] += token[1];
|
347
|
-
lastToken[3] = token[3];
|
348
|
-
} else {
|
349
|
-
lastToken = token;
|
350
|
-
squashedTokens.push(token);
|
351
|
-
}
|
352
|
-
}
|
353
|
-
}
|
354
|
-
|
355
|
-
return squashedTokens;
|
356
|
-
}
|
357
|
-
|
358
|
-
function escapeTags(tags) {
|
359
|
-
return [
|
360
|
-
new RegExp(escapeRe(tags[0]) + "\\s*"),
|
361
|
-
new RegExp("\\s*" + escapeRe(tags[1]))
|
362
|
-
];
|
363
|
-
}
|
364
|
-
|
365
|
-
/**
|
366
|
-
* Breaks up the given `template` string into a tree of token objects. If
|
367
|
-
* `tags` is given here it must be an array with two string values: the
|
368
|
-
* opening and closing tags used in the template (e.g. ["<%", "%>"]). Of
|
369
|
-
* course, the default is to use mustaches (i.e. Mustache.tags).
|
370
|
-
*/
|
371
|
-
exports.parse = function (template, tags) {
|
372
|
-
template = template || '';
|
373
|
-
tags = tags || exports.tags;
|
374
|
-
|
375
|
-
if (typeof tags === 'string') tags = tags.split(spaceRe);
|
376
|
-
if (tags.length !== 2) throw new Error('Invalid tags: ' + tags.join(', '));
|
377
|
-
|
378
|
-
var tagRes = escapeTags(tags);
|
379
|
-
var scanner = new Scanner(template);
|
380
|
-
|
381
|
-
var sections = []; // Stack to hold section tokens
|
382
|
-
var tokens = []; // Buffer to hold the tokens
|
383
|
-
var spaces = []; // Indices of whitespace tokens on the current line
|
384
|
-
var hasTag = false; // Is there a {{tag}} on the current line?
|
385
|
-
var nonSpace = false; // Is there a non-space char on the current line?
|
386
|
-
|
387
|
-
// Strips all whitespace tokens array for the current line
|
388
|
-
// if there was a {{#tag}} on it and otherwise only space.
|
389
|
-
function stripSpace() {
|
390
|
-
if (hasTag && !nonSpace) {
|
391
|
-
while (spaces.length) {
|
392
|
-
delete tokens[spaces.pop()];
|
393
|
-
}
|
394
|
-
} else {
|
395
|
-
spaces = [];
|
396
|
-
}
|
397
|
-
|
398
|
-
hasTag = false;
|
399
|
-
nonSpace = false;
|
400
|
-
}
|
401
|
-
|
402
|
-
var start, type, value, chr, token;
|
403
|
-
while (!scanner.eos()) {
|
404
|
-
start = scanner.pos;
|
405
|
-
|
406
|
-
// Match any text between tags.
|
407
|
-
value = scanner.scanUntil(tagRes[0]);
|
408
|
-
if (value) {
|
409
|
-
for (var i = 0, len = value.length; i < len; ++i) {
|
410
|
-
chr = value.charAt(i);
|
411
|
-
|
412
|
-
if (isWhitespace(chr)) {
|
413
|
-
spaces.push(tokens.length);
|
414
|
-
} else {
|
415
|
-
nonSpace = true;
|
416
|
-
}
|
417
|
-
|
418
|
-
tokens.push(['text', chr, start, start + 1]);
|
419
|
-
start += 1;
|
420
|
-
|
421
|
-
// Check for whitespace on the current line.
|
422
|
-
if (chr == '\n') stripSpace();
|
423
|
-
}
|
424
|
-
}
|
425
|
-
|
426
|
-
// Match the opening tag.
|
427
|
-
if (!scanner.scan(tagRes[0])) break;
|
428
|
-
hasTag = true;
|
429
|
-
|
430
|
-
// Get the tag type.
|
431
|
-
type = scanner.scan(tagRe) || 'name';
|
432
|
-
scanner.scan(whiteRe);
|
433
|
-
|
434
|
-
// Get the tag value.
|
435
|
-
if (type === '=') {
|
436
|
-
value = scanner.scanUntil(eqRe);
|
437
|
-
scanner.scan(eqRe);
|
438
|
-
scanner.scanUntil(tagRes[1]);
|
439
|
-
} else if (type === '{') {
|
440
|
-
value = scanner.scanUntil(new RegExp('\\s*' + escapeRe('}' + tags[1])));
|
441
|
-
scanner.scan(curlyRe);
|
442
|
-
scanner.scanUntil(tagRes[1]);
|
443
|
-
type = '&';
|
444
|
-
} else {
|
445
|
-
value = scanner.scanUntil(tagRes[1]);
|
446
|
-
}
|
447
|
-
|
448
|
-
// Match the closing tag.
|
449
|
-
if (!scanner.scan(tagRes[1])) throw new Error('Unclosed tag at ' + scanner.pos);
|
450
|
-
|
451
|
-
token = [type, value, start, scanner.pos];
|
452
|
-
tokens.push(token);
|
453
|
-
|
454
|
-
if (type === '#' || type === '^') {
|
455
|
-
sections.push(token);
|
456
|
-
} else if (type === '/') {
|
457
|
-
// Check section nesting.
|
458
|
-
if (sections.length === 0) throw new Error('Unopened section "' + value + '" at ' + start);
|
459
|
-
var openSection = sections.pop();
|
460
|
-
if (openSection[1] !== value) throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
|
461
|
-
} else if (type === 'name' || type === '{' || type === '&') {
|
462
|
-
nonSpace = true;
|
463
|
-
} else if (type === '=') {
|
464
|
-
// Set the tags for the next time around.
|
465
|
-
tags = value.split(spaceRe);
|
466
|
-
if (tags.length !== 2) throw new Error('Invalid tags at ' + start + ': ' + tags.join(', '));
|
467
|
-
tagRes = escapeTags(tags);
|
468
|
-
}
|
469
|
-
}
|
470
|
-
|
471
|
-
// Make sure there are no open sections when we're done.
|
472
|
-
var openSection = sections.pop();
|
473
|
-
if (openSection) throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
|
474
|
-
|
475
|
-
tokens = squashTokens(tokens);
|
476
|
-
|
477
|
-
return nestTokens(tokens);
|
478
|
-
};
|
479
|
-
|
480
|
-
// All Mustache.* functions use this writer.
|
481
|
-
var _writer = new Writer();
|
482
|
-
|
483
|
-
/**
|
484
|
-
* Clears all cached templates and partials in the default writer.
|
485
|
-
*/
|
486
|
-
exports.clearCache = function () {
|
487
|
-
return _writer.clearCache();
|
488
|
-
};
|
489
|
-
|
490
|
-
/**
|
491
|
-
* Compiles the given `template` to a reusable function using the default
|
492
|
-
* writer.
|
493
|
-
*/
|
494
|
-
exports.compile = function (template, tags) {
|
495
|
-
return _writer.compile(template, tags);
|
496
|
-
};
|
497
|
-
|
498
|
-
/**
|
499
|
-
* Compiles the partial with the given `name` and `template` to a reusable
|
500
|
-
* function using the default writer.
|
501
|
-
*/
|
502
|
-
exports.compilePartial = function (name, template, tags) {
|
503
|
-
return _writer.compilePartial(name, template, tags);
|
504
|
-
};
|
505
|
-
|
506
|
-
/**
|
507
|
-
* Compiles the given array of tokens (the output of a parse) to a reusable
|
508
|
-
* function using the default writer.
|
509
|
-
*/
|
510
|
-
exports.compileTokens = function (tokens, template) {
|
511
|
-
return _writer.compileTokens(tokens, template);
|
512
|
-
};
|
513
|
-
|
514
|
-
/**
|
515
|
-
* Renders the `template` with the given `view` and `partials` using the
|
516
|
-
* default writer.
|
517
|
-
*/
|
518
|
-
exports.render = function (template, view, partials) {
|
519
|
-
return _writer.render(template, view, partials);
|
520
|
-
};
|
521
|
-
|
522
|
-
// This is here for backwards compatibility with 0.4.x.
|
523
|
-
exports.to_html = function (template, view, partials, send) {
|
524
|
-
var result = exports.render(template, view, partials);
|
525
|
-
|
526
|
-
if (typeof send === "function") {
|
527
|
-
send(result);
|
528
|
-
} else {
|
529
|
-
return result;
|
530
|
-
}
|
531
|
-
};
|
532
|
-
|
533
|
-
return exports;
|
534
|
-
|
535
|
-
}())));
|