1 | var require = function (file, cwd) {
|
2 | var resolved = require.resolve(file, cwd || '/');
|
3 | var mod = require.modules[resolved];
|
4 | if (!mod) throw new Error(
|
5 | 'Failed to resolve module ' + file + ', tried ' + resolved
|
6 | );
|
7 | var cached = require.cache[resolved];
|
8 | var res = cached? cached.exports : mod();
|
9 | return res;
|
10 | };
|
11 |
|
12 | require.paths = [];
|
13 | require.modules = {};
|
14 | require.cache = {};
|
15 | require.extensions = [".js",".coffee",".json"];
|
16 |
|
17 | require._core = {
|
18 | 'assert': true,
|
19 | 'events': true,
|
20 | 'fs': true,
|
21 | 'path': true,
|
22 | 'vm': true
|
23 | };
|
24 |
|
25 | require.resolve = (function () {
|
26 | return function (x, cwd) {
|
27 | if (!cwd) cwd = '/';
|
28 |
|
29 | if (require._core[x]) return x;
|
30 | var path = require.modules.path();
|
31 | cwd = path.resolve('/', cwd);
|
32 | var y = cwd || '/';
|
33 |
|
34 | if (x.match(/^(?:\.\.?\/|\/)/)) {
|
35 | var m = loadAsFileSync(path.resolve(y, x))
|
36 | || loadAsDirectorySync(path.resolve(y, x));
|
37 | if (m) return m;
|
38 | }
|
39 |
|
40 | var n = loadNodeModulesSync(x, y);
|
41 | if (n) return n;
|
42 |
|
43 | throw new Error("Cannot find module '" + x + "'");
|
44 |
|
45 | function loadAsFileSync (x) {
|
46 | x = path.normalize(x);
|
47 | if (require.modules[x]) {
|
48 | return x;
|
49 | }
|
50 |
|
51 | for (var i = 0; i < require.extensions.length; i++) {
|
52 | var ext = require.extensions[i];
|
53 | if (require.modules[x + ext]) return x + ext;
|
54 | }
|
55 | }
|
56 |
|
57 | function loadAsDirectorySync (x) {
|
58 | x = x.replace(/\/+$/, '');
|
59 | var pkgfile = path.normalize(x + '/package.json');
|
60 | if (require.modules[pkgfile]) {
|
61 | var pkg = require.modules[pkgfile]();
|
62 | var b = pkg.browserify;
|
63 | if (typeof b === 'object' && b.main) {
|
64 | var m = loadAsFileSync(path.resolve(x, b.main));
|
65 | if (m) return m;
|
66 | }
|
67 | else if (typeof b === 'string') {
|
68 | var m = loadAsFileSync(path.resolve(x, b));
|
69 | if (m) return m;
|
70 | }
|
71 | else if (pkg.main) {
|
72 | var m = loadAsFileSync(path.resolve(x, pkg.main));
|
73 | if (m) return m;
|
74 | }
|
75 | }
|
76 |
|
77 | return loadAsFileSync(x + '/index');
|
78 | }
|
79 |
|
80 | function loadNodeModulesSync (x, start) {
|
81 | var dirs = nodeModulesPathsSync(start);
|
82 | for (var i = 0; i < dirs.length; i++) {
|
83 | var dir = dirs[i];
|
84 | var m = loadAsFileSync(dir + '/' + x);
|
85 | if (m) return m;
|
86 | var n = loadAsDirectorySync(dir + '/' + x);
|
87 | if (n) return n;
|
88 | }
|
89 |
|
90 | var m = loadAsFileSync(x);
|
91 | if (m) return m;
|
92 | }
|
93 |
|
94 | function nodeModulesPathsSync (start) {
|
95 | var parts;
|
96 | if (start === '/') parts = [ '' ];
|
97 | else parts = path.normalize(start).split('/');
|
98 |
|
99 | var dirs = [];
|
100 | for (var i = parts.length - 1; i >= 0; i--) {
|
101 | if (parts[i] === 'node_modules') continue;
|
102 | var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
|
103 | dirs.push(dir);
|
104 | }
|
105 |
|
106 | return dirs;
|
107 | }
|
108 | };
|
109 | })();
|
110 |
|
111 | require.alias = function (from, to) {
|
112 | var path = require.modules.path();
|
113 | var res = null;
|
114 | try {
|
115 | res = require.resolve(from + '/package.json', '/');
|
116 | }
|
117 | catch (err) {
|
118 | res = require.resolve(from, '/');
|
119 | }
|
120 | var basedir = path.dirname(res);
|
121 |
|
122 | var keys = (Object.keys || function (obj) {
|
123 | var res = [];
|
124 | for (var key in obj) res.push(key);
|
125 | return res;
|
126 | })(require.modules);
|
127 |
|
128 | for (var i = 0; i < keys.length; i++) {
|
129 | var key = keys[i];
|
130 | if (key.slice(0, basedir.length + 1) === basedir + '/') {
|
131 | var f = key.slice(basedir.length);
|
132 | require.modules[to + f] = require.modules[basedir + f];
|
133 | }
|
134 | else if (key === basedir) {
|
135 | require.modules[to] = require.modules[basedir];
|
136 | }
|
137 | }
|
138 | };
|
139 |
|
140 | (function () {
|
141 | var process = {};
|
142 | var global = typeof window !== 'undefined' ? window : {};
|
143 | var definedProcess = false;
|
144 |
|
145 | require.define = function (filename, fn) {
|
146 | if (!definedProcess && require.modules.__browserify_process) {
|
147 | process = require.modules.__browserify_process();
|
148 | definedProcess = true;
|
149 | }
|
150 |
|
151 | var dirname = require._core[filename]
|
152 | ? ''
|
153 | : require.modules.path().dirname(filename)
|
154 | ;
|
155 |
|
156 | var require_ = function (file) {
|
157 | var requiredModule = require(file, dirname);
|
158 | var cached = require.cache[require.resolve(file, dirname)];
|
159 |
|
160 | if (cached && cached.parent === null) {
|
161 | cached.parent = module_;
|
162 | }
|
163 |
|
164 | return requiredModule;
|
165 | };
|
166 | require_.resolve = function (name) {
|
167 | return require.resolve(name, dirname);
|
168 | };
|
169 | require_.modules = require.modules;
|
170 | require_.define = require.define;
|
171 | require_.cache = require.cache;
|
172 | var module_ = {
|
173 | id : filename,
|
174 | filename: filename,
|
175 | exports : {},
|
176 | loaded : false,
|
177 | parent: null
|
178 | };
|
179 |
|
180 | require.modules[filename] = function () {
|
181 | require.cache[filename] = module_;
|
182 | fn.call(
|
183 | module_.exports,
|
184 | require_,
|
185 | module_,
|
186 | module_.exports,
|
187 | dirname,
|
188 | filename,
|
189 | process,
|
190 | global
|
191 | );
|
192 | module_.loaded = true;
|
193 | return module_.exports;
|
194 | };
|
195 | };
|
196 | })();
|
197 |
|
198 |
|
199 | require.define("path",function(require,module,exports,__dirname,__filename,process,global){function filter (xs, fn) {
|
200 | var res = [];
|
201 | for (var i = 0; i < xs.length; i++) {
|
202 | if (fn(xs[i], i, xs)) res.push(xs[i]);
|
203 | }
|
204 | return res;
|
205 | }
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 | function normalizeArray(parts, allowAboveRoot) {
|
212 |
|
213 | var up = 0;
|
214 | for (var i = parts.length; i >= 0; i--) {
|
215 | var last = parts[i];
|
216 | if (last == '.') {
|
217 | parts.splice(i, 1);
|
218 | } else if (last === '..') {
|
219 | parts.splice(i, 1);
|
220 | up++;
|
221 | } else if (up) {
|
222 | parts.splice(i, 1);
|
223 | up--;
|
224 | }
|
225 | }
|
226 |
|
227 |
|
228 | if (allowAboveRoot) {
|
229 | for (; up--; up) {
|
230 | parts.unshift('..');
|
231 | }
|
232 | }
|
233 |
|
234 | return parts;
|
235 | }
|
236 |
|
237 |
|
238 |
|
239 | var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;
|
240 |
|
241 |
|
242 |
|
243 | exports.resolve = function() {
|
244 | var resolvedPath = '',
|
245 | resolvedAbsolute = false;
|
246 |
|
247 | for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
|
248 | var path = (i >= 0)
|
249 | ? arguments[i]
|
250 | : process.cwd();
|
251 |
|
252 |
|
253 | if (typeof path !== 'string' || !path) {
|
254 | continue;
|
255 | }
|
256 |
|
257 | resolvedPath = path + '/' + resolvedPath;
|
258 | resolvedAbsolute = path.charAt(0) === '/';
|
259 | }
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 | resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
266 | return !!p;
|
267 | }), !resolvedAbsolute).join('/');
|
268 |
|
269 | return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
270 | };
|
271 |
|
272 |
|
273 |
|
274 | exports.normalize = function(path) {
|
275 | var isAbsolute = path.charAt(0) === '/',
|
276 | trailingSlash = path.slice(-1) === '/';
|
277 |
|
278 |
|
279 | path = normalizeArray(filter(path.split('/'), function(p) {
|
280 | return !!p;
|
281 | }), !isAbsolute).join('/');
|
282 |
|
283 | if (!path && !isAbsolute) {
|
284 | path = '.';
|
285 | }
|
286 | if (path && trailingSlash) {
|
287 | path += '/';
|
288 | }
|
289 |
|
290 | return (isAbsolute ? '/' : '') + path;
|
291 | };
|
292 |
|
293 |
|
294 |
|
295 | exports.join = function() {
|
296 | var paths = Array.prototype.slice.call(arguments, 0);
|
297 | return exports.normalize(filter(paths, function(p, index) {
|
298 | return p && typeof p === 'string';
|
299 | }).join('/'));
|
300 | };
|
301 |
|
302 |
|
303 | exports.dirname = function(path) {
|
304 | var dir = splitPathRe.exec(path)[1] || '';
|
305 | var isWindows = false;
|
306 | if (!dir) {
|
307 |
|
308 | return '.';
|
309 | } else if (dir.length === 1 ||
|
310 | (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
|
311 |
|
312 | return dir;
|
313 | } else {
|
314 |
|
315 | return dir.substring(0, dir.length - 1);
|
316 | }
|
317 | };
|
318 |
|
319 |
|
320 | exports.basename = function(path, ext) {
|
321 | var f = splitPathRe.exec(path)[2] || '';
|
322 |
|
323 | if (ext && f.substr(-1 * ext.length) === ext) {
|
324 | f = f.substr(0, f.length - ext.length);
|
325 | }
|
326 | return f;
|
327 | };
|
328 |
|
329 |
|
330 | exports.extname = function(path) {
|
331 | return splitPathRe.exec(path)[3] || '';
|
332 | };
|
333 |
|
334 | exports.relative = function(from, to) {
|
335 | from = exports.resolve(from).substr(1);
|
336 | to = exports.resolve(to).substr(1);
|
337 |
|
338 | function trim(arr) {
|
339 | var start = 0;
|
340 | for (; start < arr.length; start++) {
|
341 | if (arr[start] !== '') break;
|
342 | }
|
343 |
|
344 | var end = arr.length - 1;
|
345 | for (; end >= 0; end--) {
|
346 | if (arr[end] !== '') break;
|
347 | }
|
348 |
|
349 | if (start > end) return [];
|
350 | return arr.slice(start, end - start + 1);
|
351 | }
|
352 |
|
353 | var fromParts = trim(from.split('/'));
|
354 | var toParts = trim(to.split('/'));
|
355 |
|
356 | var length = Math.min(fromParts.length, toParts.length);
|
357 | var samePartsLength = length;
|
358 | for (var i = 0; i < length; i++) {
|
359 | if (fromParts[i] !== toParts[i]) {
|
360 | samePartsLength = i;
|
361 | break;
|
362 | }
|
363 | }
|
364 |
|
365 | var outputParts = [];
|
366 | for (var i = samePartsLength; i < fromParts.length; i++) {
|
367 | outputParts.push('..');
|
368 | }
|
369 |
|
370 | outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
371 |
|
372 | return outputParts.join('/');
|
373 | };
|
374 |
|
375 | });
|
376 |
|
377 | require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process,global){var process = module.exports = {};
|
378 |
|
379 | process.nextTick = (function () {
|
380 | var canSetImmediate = typeof window !== 'undefined'
|
381 | && window.setImmediate;
|
382 | var canPost = typeof window !== 'undefined'
|
383 | && window.postMessage && window.addEventListener
|
384 | ;
|
385 |
|
386 | if (canSetImmediate) {
|
387 | return function (f) { return window.setImmediate(f) };
|
388 | }
|
389 |
|
390 | if (canPost) {
|
391 | var queue = [];
|
392 | window.addEventListener('message', function (ev) {
|
393 | if (ev.source === window && ev.data === 'browserify-tick') {
|
394 | ev.stopPropagation();
|
395 | if (queue.length > 0) {
|
396 | var fn = queue.shift();
|
397 | fn();
|
398 | }
|
399 | }
|
400 | }, true);
|
401 |
|
402 | return function nextTick(fn) {
|
403 | queue.push(fn);
|
404 | window.postMessage('browserify-tick', '*');
|
405 | };
|
406 | }
|
407 |
|
408 | return function nextTick(fn) {
|
409 | setTimeout(fn, 0);
|
410 | };
|
411 | })();
|
412 |
|
413 | process.title = 'browser';
|
414 | process.browser = true;
|
415 | process.env = {};
|
416 | process.argv = [];
|
417 |
|
418 | process.binding = function (name) {
|
419 | if (name === 'evals') return (require)('vm')
|
420 | else throw new Error('No such module. (Possibly not yet loaded)')
|
421 | };
|
422 |
|
423 | (function () {
|
424 | var cwd = '/';
|
425 | var path;
|
426 | process.cwd = function () { return cwd };
|
427 | process.chdir = function (dir) {
|
428 | if (!path) path = require('path');
|
429 | cwd = path.resolve(dir, cwd);
|
430 | };
|
431 | })();
|
432 |
|
433 | });
|
434 |
|
435 | require.define("/haml-coffee.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
436 | var Code, Comment, Directive, Filter, Haml, HamlCoffee, Node, Text, indent, whitespace;
|
437 |
|
438 | Node = require('./nodes/node');
|
439 |
|
440 | Text = require('./nodes/text');
|
441 |
|
442 | Haml = require('./nodes/haml');
|
443 |
|
444 | Code = require('./nodes/code');
|
445 |
|
446 | Comment = require('./nodes/comment');
|
447 |
|
448 | Filter = require('./nodes/filter');
|
449 |
|
450 | Directive = require('./nodes/directive');
|
451 |
|
452 | whitespace = require('./util/text').whitespace;
|
453 |
|
454 | indent = require('./util/text').indent;
|
455 |
|
456 | module.exports = HamlCoffee = (function() {
|
457 | HamlCoffee.VERSION = '1.11.0';
|
458 |
|
459 | function HamlCoffee(options) {
|
460 | var segment, segments, _base, _base1, _base10, _base11, _base12, _base13, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9, _i, _len, _ref, _ref1, _ref10, _ref11, _ref12, _ref13, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
|
461 |
|
462 | this.options = options != null ? options : {};
|
463 | if ((_ref = (_base = this.options).placement) == null) {
|
464 | _base.placement = 'global';
|
465 | }
|
466 | if ((_ref1 = (_base1 = this.options).dependencies) == null) {
|
467 | _base1.dependencies = {
|
468 | hc: 'hamlcoffee'
|
469 | };
|
470 | }
|
471 | if ((_ref2 = (_base2 = this.options).escapeHtml) == null) {
|
472 | _base2.escapeHtml = true;
|
473 | }
|
474 | if ((_ref3 = (_base3 = this.options).escapeAttributes) == null) {
|
475 | _base3.escapeAttributes = true;
|
476 | }
|
477 | if ((_ref4 = (_base4 = this.options).cleanValue) == null) {
|
478 | _base4.cleanValue = true;
|
479 | }
|
480 | if ((_ref5 = (_base5 = this.options).uglify) == null) {
|
481 | _base5.uglify = false;
|
482 | }
|
483 | if ((_ref6 = (_base6 = this.options).basename) == null) {
|
484 | _base6.basename = false;
|
485 | }
|
486 | if ((_ref7 = (_base7 = this.options).extendScope) == null) {
|
487 | _base7.extendScope = false;
|
488 | }
|
489 | if ((_ref8 = (_base8 = this.options).format) == null) {
|
490 | _base8.format = 'html5';
|
491 | }
|
492 | if ((_ref9 = (_base9 = this.options).hyphenateDataAttrs) == null) {
|
493 | _base9.hyphenateDataAttrs = true;
|
494 | }
|
495 | if ((_ref10 = (_base10 = this.options).preserveTags) == null) {
|
496 | _base10.preserveTags = 'pre,textarea';
|
497 | }
|
498 | if ((_ref11 = (_base11 = this.options).selfCloseTags) == null) {
|
499 | _base11.selfCloseTags = 'meta,img,link,br,hr,input,area,param,col,base';
|
500 | }
|
501 | if (this.options.placement === 'global') {
|
502 | if ((_ref12 = (_base12 = this.options).name) == null) {
|
503 | _base12.name = 'test';
|
504 | }
|
505 | if ((_ref13 = (_base13 = this.options).namespace) == null) {
|
506 | _base13.namespace = 'window.HAML';
|
507 | }
|
508 | segments = ("" + this.options.namespace + "." + this.options.name).replace(/(\s|-)+/g, '_').split(/\./);
|
509 | this.options.name = this.options.basename ? segments.pop().split(/\/|\\/).pop() : segments.pop();
|
510 | this.options.namespace = segments.shift();
|
511 | this.intro = '';
|
512 | if (segments.length !== 0) {
|
513 | for (_i = 0, _len = segments.length; _i < _len; _i++) {
|
514 | segment = segments[_i];
|
515 | this.options.namespace += "." + segment;
|
516 | this.intro += "" + this.options.namespace + " ?= {}\n";
|
517 | }
|
518 | } else {
|
519 | this.intro += "" + this.options.namespace + " ?= {}\n";
|
520 | }
|
521 | }
|
522 | }
|
523 |
|
524 | HamlCoffee.prototype.indentChanged = function() {
|
525 | return this.currentIndent !== this.previousIndent;
|
526 | };
|
527 |
|
528 | HamlCoffee.prototype.isIndent = function() {
|
529 | return this.currentIndent > this.previousIndent;
|
530 | };
|
531 |
|
532 | HamlCoffee.prototype.updateTabSize = function() {
|
533 | if (this.tabSize === 0) {
|
534 | return this.tabSize = this.currentIndent - this.previousIndent;
|
535 | }
|
536 | };
|
537 |
|
538 | HamlCoffee.prototype.updateBlockLevel = function() {
|
539 | this.currentBlockLevel = this.currentIndent / this.tabSize;
|
540 | if (this.currentBlockLevel - Math.floor(this.currentBlockLevel) > 0) {
|
541 | throw "Indentation error in line " + this.lineNumber;
|
542 | }
|
543 | if ((this.currentIndent - this.previousIndent) / this.tabSize > 1) {
|
544 | if (!this.node.isCommented()) {
|
545 | throw "Block level too deep in line " + this.lineNumber;
|
546 | }
|
547 | }
|
548 | return this.delta = this.previousBlockLevel - this.currentBlockLevel;
|
549 | };
|
550 |
|
551 | HamlCoffee.prototype.updateCodeBlockLevel = function(node) {
|
552 | if (node instanceof Code) {
|
553 | return this.currentCodeBlockLevel = node.codeBlockLevel + 1;
|
554 | } else {
|
555 | return this.currentCodeBlockLevel = node.codeBlockLevel;
|
556 | }
|
557 | };
|
558 |
|
559 | HamlCoffee.prototype.updateParent = function() {
|
560 | if (this.isIndent()) {
|
561 | return this.pushParent();
|
562 | } else {
|
563 | return this.popParent();
|
564 | }
|
565 | };
|
566 |
|
567 | HamlCoffee.prototype.pushParent = function() {
|
568 | this.stack.push(this.parentNode);
|
569 | return this.parentNode = this.node;
|
570 | };
|
571 |
|
572 | HamlCoffee.prototype.popParent = function() {
|
573 | var i, _i, _ref, _results;
|
574 |
|
575 | _results = [];
|
576 | for (i = _i = 0, _ref = this.delta - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; i = 0 <= _ref ? ++_i : --_i) {
|
577 | _results.push(this.parentNode = this.stack.pop());
|
578 | }
|
579 | return _results;
|
580 | };
|
581 |
|
582 | HamlCoffee.prototype.getNodeOptions = function(override) {
|
583 | if (override == null) {
|
584 | override = {};
|
585 | }
|
586 | return {
|
587 | parentNode: override.parentNode || this.parentNode,
|
588 | blockLevel: override.blockLevel || this.currentBlockLevel,
|
589 | codeBlockLevel: override.codeBlockLevel || this.currentCodeBlockLevel,
|
590 | escapeHtml: override.escapeHtml || this.options.escapeHtml,
|
591 | escapeAttributes: override.escapeAttributes || this.options.escapeAttributes,
|
592 | cleanValue: override.cleanValue || this.options.cleanValue,
|
593 | format: override.format || this.options.format,
|
594 | hyphenateDataAttrs: override.hyphenateDataAttrs || this.options.format,
|
595 | preserveTags: override.preserveTags || this.options.preserveTags,
|
596 | selfCloseTags: override.selfCloseTags || this.options.selfCloseTags,
|
597 | uglify: override.uglify || this.options.uglify,
|
598 | placement: override.placement || this.options.placement,
|
599 | namespace: override.namespace || this.options.namespace,
|
600 | name: override.name || this.options.name
|
601 | };
|
602 | };
|
603 |
|
604 | HamlCoffee.prototype.nodeFactory = function(expression) {
|
605 | var node, options, _ref;
|
606 |
|
607 | if (expression == null) {
|
608 | expression = '';
|
609 | }
|
610 | options = this.getNodeOptions();
|
611 | if (expression.match(/^:(escaped|preserve|css|javascript|plain|cdata|coffeescript)/)) {
|
612 | node = new Filter(expression, options);
|
613 | } else if (expression.match(/^(\/|-#)(.*)/)) {
|
614 | node = new Comment(expression, options);
|
615 | } else if (expression.match(/^(-#|-|=|!=|\&=|~)\s*(.*)/)) {
|
616 | node = new Code(expression, options);
|
617 | } else if (expression.match(/^(%|#[^{]|\.|\!)(.*)/)) {
|
618 | node = new Haml(expression, options);
|
619 | } else if (expression.match(/^\+(.*)/)) {
|
620 | node = new Directive(expression, options);
|
621 | } else {
|
622 | node = new Text(expression, options);
|
623 | }
|
624 | if ((_ref = options.parentNode) != null) {
|
625 | _ref.addChild(node);
|
626 | }
|
627 | return node;
|
628 | };
|
629 |
|
630 | HamlCoffee.prototype.parse = function(source) {
|
631 | var attributes, expression, line, lines, result, text, ws, _ref;
|
632 |
|
633 | if (source == null) {
|
634 | source = '';
|
635 | }
|
636 | this.lineNumber = this.previousIndent = this.tabSize = this.currentBlockLevel = this.previousBlockLevel = 0;
|
637 | this.currentCodeBlockLevel = this.previousCodeBlockLevel = 0;
|
638 | this.node = null;
|
639 | this.stack = [];
|
640 | this.root = this.parentNode = new Node('', this.getNodeOptions());
|
641 | lines = source.split("\n");
|
642 | while ((line = lines.shift()) !== void 0) {
|
643 | if ((this.node instanceof Filter) && !this.exitFilter) {
|
644 | if (/^(\s)*$/.test(line)) {
|
645 | this.node.addChild(new Text('', this.getNodeOptions({
|
646 | parentNode: this.node
|
647 | })));
|
648 | } else {
|
649 | result = line.match(/^(\s*)(.*)/);
|
650 | ws = result[1];
|
651 | expression = result[2];
|
652 | if (this.node.blockLevel >= (ws.length / 2)) {
|
653 | this.exitFilter = true;
|
654 | lines.unshift(line);
|
655 | continue;
|
656 | }
|
657 | text = line.match(RegExp("^\\s{" + ((this.node.blockLevel * 2) + 2) + "}(.*)"));
|
658 | if (text) {
|
659 | this.node.addChild(new Text(text[1], this.getNodeOptions({
|
660 | parentNode: this.node
|
661 | })));
|
662 | }
|
663 | }
|
664 | } else {
|
665 | this.exitFilter = false;
|
666 | result = line.match(/^(\s*)(.*)/);
|
667 | ws = result[1];
|
668 | expression = result[2];
|
669 | if (/^\s*$/.test(line)) {
|
670 | continue;
|
671 | }
|
672 | while (/^[%.#].*[{(]/.test(expression) && !/^(\s*)[-=&!~.%#</]/.test(lines[0]) && /([-\w]+[\w:-]*\w?)\s*=|('\w+[\w:-]*\w?')\s*=|("\w+[\w:-]*\w?")\s*=|(\w+[\w:-]*\w?):|('[-\w]+[\w:-]*\w?'):|("[-\w]+[\w:-]*\w?"):|:(\w+[\w:-]*\w?)\s*=>|:?'([-\w]+[\w:-]*\w?)'\s*=>|:?"([-\w]+[\w:-]*\w?)"\s*=>/.test(lines[0])) {
|
673 | attributes = lines.shift();
|
674 | expression = expression.replace(/(\s)+\|\s*$/, '');
|
675 | expression += ' ' + attributes.match(/^\s*(.*?)(\s+\|\s*)?$/)[1];
|
676 | this.lineNumber++;
|
677 | }
|
678 | if (expression.match(/(\s)+\|\s*$/)) {
|
679 | expression = expression.replace(/(\s)+\|\s*$/, ' ');
|
680 | while ((_ref = lines[0]) != null ? _ref.match(/(\s)+\|$/) : void 0) {
|
681 | expression += lines.shift().match(/^(\s*)(.*)/)[2].replace(/(\s)+\|\s*$/, '');
|
682 | this.lineNumber++;
|
683 | }
|
684 | }
|
685 | this.currentIndent = ws.length;
|
686 | if (this.indentChanged()) {
|
687 | this.updateTabSize();
|
688 | this.updateBlockLevel();
|
689 | this.updateParent();
|
690 | this.updateCodeBlockLevel(this.parentNode);
|
691 | }
|
692 | this.node = this.nodeFactory(expression);
|
693 | this.previousBlockLevel = this.currentBlockLevel;
|
694 | this.previousIndent = this.currentIndent;
|
695 | }
|
696 | this.lineNumber++;
|
697 | }
|
698 | return this.evaluate(this.root);
|
699 | };
|
700 |
|
701 | HamlCoffee.prototype.evaluate = function(node) {
|
702 | var child, _i, _len, _ref;
|
703 |
|
704 | _ref = node.children;
|
705 | for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
706 | child = _ref[_i];
|
707 | this.evaluate(child);
|
708 | }
|
709 | return node.evaluate();
|
710 | };
|
711 |
|
712 | HamlCoffee.prototype.render = function() {
|
713 | switch (this.options.placement) {
|
714 | case 'amd':
|
715 | return this.renderAmd();
|
716 | case 'standalone':
|
717 | return this.renderStandalone();
|
718 | default:
|
719 | return this.renderGlobal();
|
720 | }
|
721 | };
|
722 |
|
723 | HamlCoffee.prototype.renderStandalone = function() {
|
724 | var template;
|
725 |
|
726 | return template = "return (context) ->\n (->\n" + (indent(this.precompile(), 2)) + "\n ).call(context)";
|
727 | };
|
728 |
|
729 | HamlCoffee.prototype.renderAmd = function() {
|
730 | var m, module, modules, param, params, template, _ref, _ref1;
|
731 |
|
732 | if (/^hamlcoffee/.test(this.options.dependencies['hc'])) {
|
733 | this.options.customHtmlEscape = 'hc.escape';
|
734 | this.options.customCleanValue = 'hc.cleanValue';
|
735 | this.options.customPreserve = 'hc.preserve';
|
736 | this.options.customFindAndPreserve = 'hc.findAndPreserve';
|
737 | this.options.customSurround = 'hc.surround';
|
738 | this.options.customSucceed = 'hc.succeed';
|
739 | this.options.customPrecede = 'hc.precede';
|
740 | this.options.customReference = 'hc.reference';
|
741 | }
|
742 | modules = [];
|
743 | params = [];
|
744 | _ref = this.options.dependencies;
|
745 | for (param in _ref) {
|
746 | module = _ref[param];
|
747 | modules.push(module);
|
748 | params.push(param);
|
749 | }
|
750 | template = indent(this.precompile(), 4);
|
751 | _ref1 = this.findDependencies(template);
|
752 | for (param in _ref1) {
|
753 | module = _ref1[param];
|
754 | modules.push(module);
|
755 | params.push(param);
|
756 | }
|
757 | if (modules.length !== 0) {
|
758 | modules = (function() {
|
759 | var _i, _len, _results;
|
760 |
|
761 | _results = [];
|
762 | for (_i = 0, _len = modules.length; _i < _len; _i++) {
|
763 | m = modules[_i];
|
764 | _results.push("'" + m + "'");
|
765 | }
|
766 | return _results;
|
767 | })();
|
768 | modules = "[" + modules + "], (" + (params.join(', ')) + ")";
|
769 | } else {
|
770 | modules = '';
|
771 | }
|
772 | return "define " + modules + " ->\n (context) ->\n render = ->\n \n" + template + "\n render.call(context)";
|
773 | };
|
774 |
|
775 | HamlCoffee.prototype.renderGlobal = function() {
|
776 | var template;
|
777 |
|
778 | template = this.intro;
|
779 | if (this.options.extendScope) {
|
780 | template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";
|
781 | template += " `with (context || {}) {`\n";
|
782 | template += "" + (indent(this.precompile(), 1));
|
783 | template += "`}`\n";
|
784 | template += ").call(context)";
|
785 | } else {
|
786 | template += "" + this.options.namespace + "['" + this.options.name + "'] = (context) -> ( ->\n";
|
787 | template += "" + (indent(this.precompile(), 1));
|
788 | template += ").call(context)";
|
789 | }
|
790 | return template;
|
791 | };
|
792 |
|
793 | HamlCoffee.prototype.precompile = function() {
|
794 | var code, fn;
|
795 |
|
796 | fn = '';
|
797 | code = this.createCode();
|
798 | if (code.indexOf('$e') !== -1) {
|
799 | if (this.options.customHtmlEscape) {
|
800 | fn += "$e = " + this.options.customHtmlEscape + "\n";
|
801 | } else {
|
802 | fn += "$e = (text, escape) ->\n \"\#{ text }\"\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\'/g, ''')\n .replace(/\\//g, '/')\n .replace(/\"/g, '"')\n";
|
803 | }
|
804 | }
|
805 | if (code.indexOf('$c') !== -1) {
|
806 | if (this.options.customCleanValue) {
|
807 | fn += "$c = " + this.options.customCleanValue + "\n";
|
808 | } else {
|
809 | fn += "$c = (text) ->\n";
|
810 | fn += " switch text\n";
|
811 | fn += " when null, undefined then ''\n";
|
812 | fn += " when true, false then '\u0093' + text\n";
|
813 | fn += " else text\n";
|
814 | }
|
815 | }
|
816 | if (code.indexOf('$p') !== -1 || code.indexOf('$fp') !== -1) {
|
817 | if (this.options.customPreserve) {
|
818 | fn += "$p = " + this.options.customPreserve + "\n";
|
819 | } else {
|
820 | fn += "$p = (text) -> text.replace /\\n/g, '
'\n";
|
821 | }
|
822 | }
|
823 | if (code.indexOf('$fp') !== -1) {
|
824 | if (this.options.customFindAndPreserve) {
|
825 | fn += "$fp = " + this.options.customFindAndPreserve + "\n";
|
826 | } else {
|
827 | fn += "$fp = (text) ->\n text.replace /<(" + (this.options.preserveTags.split(',').join('|')) + ")>([^]*?)<\\/\\1>/g, (str, tag, content) ->\n \"<\#{ tag }>\#{ $p content }</\#{ tag }>\"\n";
|
828 | }
|
829 | }
|
830 | if (code.indexOf('surround') !== -1) {
|
831 | if (this.options.customSurround) {
|
832 | fn += "surround = (start, end, fn) => " + this.options.customSurround + ".call(@, start, end, fn)\n";
|
833 | } else {
|
834 | fn += "surround = (start, end, fn) => start + fn.call(@)?.replace(/^\s+|\s+$/g, '') + end\n";
|
835 | }
|
836 | }
|
837 | if (code.indexOf('succeed') !== -1) {
|
838 | if (this.options.customSucceed) {
|
839 | fn += "succeed = (start, end, fn) => " + this.options.customSucceed + ".call(@, start, end, fn)\n";
|
840 | } else {
|
841 | fn += "succeed = (end, fn) => fn.call(@)?.replace(/\s+$/g, '') + end\n";
|
842 | }
|
843 | }
|
844 | if (code.indexOf('precede') !== -1) {
|
845 | if (this.options.customPrecede) {
|
846 | fn += "precede = (start, end, fn) => " + this.options.customPrecede + ".call(@, start, end, fn)\n";
|
847 | } else {
|
848 | fn += "precede = (start, fn) => start + fn.call(@)?.replace(/^\s+/g, '')\n";
|
849 | }
|
850 | }
|
851 | if (code.indexOf('$r') !== -1) {
|
852 | if (this.options.customReference) {
|
853 | fn += "$r = " + this.options.customReference + "\n";
|
854 | } else {
|
855 | fn += "$r = (object, prefix) ->\n name = if prefix then prefix + '_' else ''\n\n if typeof(object.hamlObjectRef) is 'function'\n name += object.hamlObjectRef()\n else\n name += (object.constructor?.name || 'object').replace(/\W+/g, '_').replace(/([a-z\d])([A-Z])/g, '$1_$2').toLowerCase()\n\n id = if typeof(object.to_key) is 'function'\n object.to_key()\n else if typeof(object.id) is 'function'\n object.id()\n else if object.id\n object.id\n else\n object\n\n result = \"class='\#{ name }'\"\n result += \" id='\#{ name }_\#{ id }'\" if id\n";
|
856 | }
|
857 | }
|
858 | fn += "$o = []\n";
|
859 | fn += "" + code + "\n";
|
860 | return fn += "return $o.join(\"\\n\")" + (this.convertBooleans(code)) + (this.removeEmptyIDAndClass(code)) + (this.cleanupWhitespace(code)) + "\n";
|
861 | };
|
862 |
|
863 | HamlCoffee.prototype.createCode = function() {
|
864 | var child, code, line, processors, _i, _j, _len, _len1, _ref, _ref1;
|
865 |
|
866 | code = [];
|
867 | this.lines = [];
|
868 | _ref = this.root.children;
|
869 | for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
870 | child = _ref[_i];
|
871 | this.lines = this.lines.concat(child.render());
|
872 | }
|
873 | this.lines = this.combineText(this.lines);
|
874 | this.blockLevel = 0;
|
875 | _ref1 = this.lines;
|
876 | for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
877 | line = _ref1[_j];
|
878 | if (line !== null) {
|
879 | switch (line.type) {
|
880 | case 'text':
|
881 | code.push("" + (whitespace(line.cw)) + (this.getBuffer(this.blockLevel)) + ".push \"" + (whitespace(line.hw)) + line.text + "\"");
|
882 | break;
|
883 | case 'run':
|
884 | if (line.block !== 'end') {
|
885 | code.push("" + (whitespace(line.cw)) + line.code);
|
886 | } else {
|
887 | code.push("" + (whitespace(line.cw)) + (line.code.replace('$buffer', this.getBuffer(this.blockLevel))));
|
888 | this.blockLevel -= 1;
|
889 | }
|
890 | break;
|
891 | case 'insert':
|
892 | processors = '';
|
893 | if (line.findAndPreserve) {
|
894 | processors += '$fp ';
|
895 | }
|
896 | if (line.preserve) {
|
897 | processors += '$p ';
|
898 | }
|
899 | if (line.escape) {
|
900 | processors += '$e ';
|
901 | }
|
902 | if (this.options.cleanValue) {
|
903 | processors += '$c ';
|
904 | }
|
905 | code.push("" + (whitespace(line.cw)) + (this.getBuffer(this.blockLevel)) + ".push \"" + (whitespace(line.hw)) + "\" + " + processors + line.code);
|
906 | if (line.block === 'start') {
|
907 | this.blockLevel += 1;
|
908 | code.push("" + (whitespace(line.cw + 1)) + (this.getBuffer(this.blockLevel)) + " = []");
|
909 | }
|
910 | }
|
911 | }
|
912 | }
|
913 | return code.join('\n');
|
914 | };
|
915 |
|
916 | HamlCoffee.prototype.getBuffer = function(level) {
|
917 | if (level > 0) {
|
918 | return "$o" + level;
|
919 | } else {
|
920 | return '$o';
|
921 | }
|
922 | };
|
923 |
|
924 | HamlCoffee.prototype.combineText = function(lines) {
|
925 | var combined, line, nextLine;
|
926 |
|
927 | combined = [];
|
928 | while ((line = lines.shift()) !== void 0) {
|
929 | if (line.type === 'text') {
|
930 | while (lines[0] && lines[0].type === 'text' && line.cw === lines[0].cw) {
|
931 | nextLine = lines.shift();
|
932 | line.text += "\\n" + (whitespace(nextLine.hw)) + nextLine.text;
|
933 | }
|
934 | }
|
935 | combined.push(line);
|
936 | }
|
937 | return combined;
|
938 | };
|
939 |
|
940 | HamlCoffee.prototype.convertBooleans = function(code) {
|
941 | if (code.indexOf('$c') !== -1) {
|
942 | if (this.options.format === 'xhtml') {
|
943 | return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, " $1=\'$1\'").replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
|
944 | } else {
|
945 | return '.replace(/\\s(\\w+)=\'\u0093true\'/mg, \' $1\').replace(/\\s(\\w+)=\'\u0093false\'/mg, \'\')';
|
946 | }
|
947 | } else {
|
948 | return '';
|
949 | }
|
950 | };
|
951 |
|
952 | HamlCoffee.prototype.removeEmptyIDAndClass = function(code) {
|
953 | if (code.indexOf('id=') !== -1 || code.indexOf('class=') !== -1) {
|
954 | return '.replace(/\\s(?:id|class)=([\'"])(\\1)/mg, "")';
|
955 | } else {
|
956 | return '';
|
957 | }
|
958 | };
|
959 |
|
960 | HamlCoffee.prototype.cleanupWhitespace = function(code) {
|
961 | if (/\u0091|\u0092/.test(code)) {
|
962 | return ".replace(/[\\s\\n]*\\u0091/mg, '').replace(/\\u0092[\\s\\n]*/mg, '')";
|
963 | } else {
|
964 | return '';
|
965 | }
|
966 | };
|
967 |
|
968 | HamlCoffee.prototype.findDependencies = function(code) {
|
969 | var dependencies, match, module, name, requireRegexp;
|
970 |
|
971 | requireRegexp = /require(?:\s+|\()(['"])(.+?)(\1)\)?/gm;
|
972 | dependencies = {};
|
973 | while (match = requireRegexp.exec(code)) {
|
974 | module = match[2];
|
975 | name = module.split('/').pop();
|
976 | dependencies[name] = module;
|
977 | }
|
978 | return dependencies;
|
979 | };
|
980 |
|
981 | return HamlCoffee;
|
982 |
|
983 | })();
|
984 |
|
985 | }).call(this);
|
986 |
|
987 | });
|
988 |
|
989 | require.define("/nodes/node.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
990 | var Node, escapeHTML;
|
991 |
|
992 | escapeHTML = require('../util/text').escapeHTML;
|
993 |
|
994 | module.exports = Node = (function() {
|
995 | Node.CLEAR_WHITESPACE_LEFT = '\u0091';
|
996 |
|
997 | Node.CLEAR_WHITESPACE_RIGHT = '\u0092';
|
998 |
|
999 | function Node(expression, options) {
|
1000 | this.expression = expression != null ? expression : '';
|
1001 | if (options == null) {
|
1002 | options = {};
|
1003 | }
|
1004 | this.parentNode = options.parentNode;
|
1005 | this.children = [];
|
1006 | this.opener = this.closer = null;
|
1007 | this.silent = false;
|
1008 | this.preserveTags = options.preserveTags.split(',');
|
1009 | this.preserve = false;
|
1010 | this.wsRemoval = {
|
1011 | around: false,
|
1012 | inside: false
|
1013 | };
|
1014 | this.escapeHtml = options.escapeHtml;
|
1015 | this.escapeAttributes = options.escapeAttributes;
|
1016 | this.cleanValue = options.cleanValue;
|
1017 | this.format = options.format;
|
1018 | this.hyphenateDataAttrs = options.hyphenateDataAttrs;
|
1019 | this.selfCloseTags = options.selfCloseTags.split(',');
|
1020 | this.uglify = options.uglify;
|
1021 | this.codeBlockLevel = options.codeBlockLevel;
|
1022 | this.blockLevel = options.blockLevel;
|
1023 | this.placement = options.placement;
|
1024 | this.namespace = options.namespace;
|
1025 | this.name = options.name;
|
1026 | }
|
1027 |
|
1028 | Node.prototype.addChild = function(child) {
|
1029 | this.children.push(child);
|
1030 | return this;
|
1031 | };
|
1032 |
|
1033 | Node.prototype.getOpener = function() {
|
1034 | if (this.wsRemoval.around && this.opener.text) {
|
1035 | this.opener.text = Node.CLEAR_WHITESPACE_LEFT + this.opener.text;
|
1036 | }
|
1037 | if (this.wsRemoval.inside && this.opener.text) {
|
1038 | this.opener.text += Node.CLEAR_WHITESPACE_RIGHT;
|
1039 | }
|
1040 | return this.opener;
|
1041 | };
|
1042 |
|
1043 | Node.prototype.getCloser = function() {
|
1044 | if (this.wsRemoval.inside && this.closer.text) {
|
1045 | this.closer.text = Node.CLEAR_WHITESPACE_LEFT + this.closer.text;
|
1046 | }
|
1047 | if (this.wsRemoval.around && this.closer.text) {
|
1048 | this.closer.text += Node.CLEAR_WHITESPACE_RIGHT;
|
1049 | }
|
1050 | return this.closer;
|
1051 | };
|
1052 |
|
1053 | Node.prototype.isPreserved = function() {
|
1054 | if (this.preserve) {
|
1055 | return true;
|
1056 | }
|
1057 | if (this.parentNode) {
|
1058 | return this.parentNode.isPreserved();
|
1059 | } else {
|
1060 | return false;
|
1061 | }
|
1062 | };
|
1063 |
|
1064 | Node.prototype.isCommented = function() {
|
1065 | if (this.constructor.name === 'Comment') {
|
1066 | return true;
|
1067 | }
|
1068 | if (this.parentNode) {
|
1069 | return this.parentNode.isCommented();
|
1070 | } else {
|
1071 | return false;
|
1072 | }
|
1073 | };
|
1074 |
|
1075 | Node.prototype.markText = function(text, escape) {
|
1076 | if (escape == null) {
|
1077 | escape = false;
|
1078 | }
|
1079 | return {
|
1080 | type: 'text',
|
1081 | cw: this.codeBlockLevel,
|
1082 | hw: this.uglify ? 0 : this.blockLevel - this.codeBlockLevel,
|
1083 | text: escape ? escapeHTML(text) : text
|
1084 | };
|
1085 | };
|
1086 |
|
1087 | Node.prototype.markRunningCode = function(code) {
|
1088 | return {
|
1089 | type: 'run',
|
1090 | cw: this.codeBlockLevel,
|
1091 | code: code
|
1092 | };
|
1093 | };
|
1094 |
|
1095 | Node.prototype.markInsertingCode = function(code, escape, preserve, findAndPreserve) {
|
1096 | if (escape == null) {
|
1097 | escape = false;
|
1098 | }
|
1099 | if (preserve == null) {
|
1100 | preserve = false;
|
1101 | }
|
1102 | if (findAndPreserve == null) {
|
1103 | findAndPreserve = false;
|
1104 | }
|
1105 | return {
|
1106 | type: 'insert',
|
1107 | cw: this.codeBlockLevel,
|
1108 | hw: this.uglify ? 0 : this.blockLevel - this.codeBlockLevel,
|
1109 | escape: escape,
|
1110 | preserve: preserve,
|
1111 | findAndPreserve: findAndPreserve,
|
1112 | code: code
|
1113 | };
|
1114 | };
|
1115 |
|
1116 | Node.prototype.evaluate = function() {};
|
1117 |
|
1118 | Node.prototype.render = function() {
|
1119 | var child, output, rendered, tag, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
|
1120 |
|
1121 | output = [];
|
1122 | if (this.silent) {
|
1123 | return output;
|
1124 | }
|
1125 | if (this.children.length === 0) {
|
1126 | if (this.opener && this.closer) {
|
1127 | tag = this.getOpener();
|
1128 | tag.text += this.getCloser().text;
|
1129 | output.push(tag);
|
1130 | } else {
|
1131 | if (!this.preserve && this.isPreserved()) {
|
1132 | output.push(this.getOpener());
|
1133 | } else {
|
1134 | output.push(this.getOpener());
|
1135 | }
|
1136 | }
|
1137 | } else {
|
1138 | if (this.opener && this.closer) {
|
1139 | if (this.preserve) {
|
1140 | this.wsRemoval.inside = true;
|
1141 | output.push(this.getOpener());
|
1142 | _ref = this.children;
|
1143 | for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
1144 | child = _ref[_i];
|
1145 | _ref1 = child.render();
|
1146 | for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
1147 | rendered = _ref1[_j];
|
1148 | rendered.hw = this.blockLevel;
|
1149 | output.push(rendered);
|
1150 | }
|
1151 | }
|
1152 | output.push(this.getCloser());
|
1153 | } else {
|
1154 | output.push(this.getOpener());
|
1155 | _ref2 = this.children;
|
1156 | for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
1157 | child = _ref2[_k];
|
1158 | output = output.concat(child.render());
|
1159 | }
|
1160 | output.push(this.getCloser());
|
1161 | }
|
1162 | } else if (this.opener) {
|
1163 | output.push(this.getOpener());
|
1164 | _ref3 = this.children;
|
1165 | for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
1166 | child = _ref3[_l];
|
1167 | output = output.concat(child.render());
|
1168 | }
|
1169 | } else {
|
1170 | _ref4 = this.children;
|
1171 | for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
|
1172 | child = _ref4[_m];
|
1173 | output.push(this.markText(child.render().text));
|
1174 | }
|
1175 | }
|
1176 | }
|
1177 | return output;
|
1178 | };
|
1179 |
|
1180 | return Node;
|
1181 |
|
1182 | })();
|
1183 |
|
1184 | }).call(this);
|
1185 |
|
1186 | });
|
1187 |
|
1188 | require.define("/util/text.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1189 | module.exports = {
|
1190 | whitespace: function(n) {
|
1191 | var a;
|
1192 |
|
1193 | n = n * 2;
|
1194 | a = [];
|
1195 | while (a.length < n) {
|
1196 | a.push(' ');
|
1197 | }
|
1198 | return a.join('');
|
1199 | },
|
1200 | escapeQuotes: function(text) {
|
1201 | if (!text) {
|
1202 | return '';
|
1203 | }
|
1204 | return text.replace(/"/g, '\\"').replace(/\\\\\"/g, '\\"');
|
1205 | },
|
1206 | unescapeQuotes: function(text) {
|
1207 | if (!text) {
|
1208 | return '';
|
1209 | }
|
1210 | return text.replace(/\\"/g, '"');
|
1211 | },
|
1212 | escapeHTML: function(text) {
|
1213 | if (!text) {
|
1214 | return '';
|
1215 | }
|
1216 | return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"');
|
1217 | },
|
1218 | preserve: function(code) {
|
1219 | if (code) {
|
1220 | return code.replace(/<(pre|textarea)>(.*?)<\/\1>/g, function(text) {
|
1221 | return text.replace('\\n', '\&\#x000A;');
|
1222 | });
|
1223 | }
|
1224 | },
|
1225 | indent: function(text, spaces) {
|
1226 | return text.replace(/^(.*)$/mg, module.exports.whitespace(spaces) + '$1');
|
1227 | }
|
1228 | };
|
1229 |
|
1230 | }).call(this);
|
1231 |
|
1232 | });
|
1233 |
|
1234 | require.define("/nodes/text.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1235 | var Node, Text, escapeQuotes, _ref,
|
1236 | __hasProp = {}.hasOwnProperty,
|
1237 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1238 |
|
1239 | Node = require('./node');
|
1240 |
|
1241 | escapeQuotes = require('../util/text').escapeQuotes;
|
1242 |
|
1243 | module.exports = Text = (function(_super) {
|
1244 | __extends(Text, _super);
|
1245 |
|
1246 | function Text() {
|
1247 | _ref = Text.__super__.constructor.apply(this, arguments);
|
1248 | return _ref;
|
1249 | }
|
1250 |
|
1251 | Text.prototype.evaluate = function() {
|
1252 | return this.opener = this.markText(escapeQuotes(this.expression));
|
1253 | };
|
1254 |
|
1255 | return Text;
|
1256 |
|
1257 | })(Node);
|
1258 |
|
1259 | }).call(this);
|
1260 |
|
1261 | });
|
1262 |
|
1263 | require.define("/nodes/haml.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1264 | var Haml, Node, escapeQuotes, _ref,
|
1265 | __hasProp = {}.hasOwnProperty,
|
1266 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1267 |
|
1268 | Node = require('./node');
|
1269 |
|
1270 | escapeQuotes = require('../util/text').escapeQuotes;
|
1271 |
|
1272 | module.exports = Haml = (function(_super) {
|
1273 | __extends(Haml, _super);
|
1274 |
|
1275 | function Haml() {
|
1276 | _ref = Haml.__super__.constructor.apply(this, arguments);
|
1277 | return _ref;
|
1278 | }
|
1279 |
|
1280 | Haml.prototype.evaluate = function() {
|
1281 | var assignment, code, identifier, match, prefix, tokens;
|
1282 |
|
1283 | tokens = this.parseExpression(this.expression);
|
1284 | if (tokens.doctype) {
|
1285 | return this.opener = this.markText("" + (escapeQuotes(this.buildDocType(tokens.doctype))));
|
1286 | } else {
|
1287 | if (this.isNotSelfClosing(tokens.tag)) {
|
1288 | prefix = this.buildHtmlTagPrefix(tokens);
|
1289 | if (tokens.assignment) {
|
1290 | match = tokens.assignment.match(/^(=|!=|&=|~)\s*(.*)$/);
|
1291 | identifier = match[1];
|
1292 | assignment = match[2];
|
1293 | if (identifier === '~') {
|
1294 | code = "\#{$fp " + assignment + " }";
|
1295 | } else if (identifier === '&=' || (identifier === '=' && this.escapeHtml)) {
|
1296 | if (this.preserve) {
|
1297 | if (this.cleanValue) {
|
1298 | code = "\#{ $p($e($c(" + assignment + "))) }";
|
1299 | } else {
|
1300 | code = "\#{ $p($e(" + assignment + ")) }";
|
1301 | }
|
1302 | } else {
|
1303 | if (this.cleanValue) {
|
1304 | code = "\#{ $e($c(" + assignment + ")) }";
|
1305 | } else {
|
1306 | code = "\#{ $e(" + assignment + ") }";
|
1307 | }
|
1308 | }
|
1309 | } else if (identifier === '!=' || (identifier === '=' && !this.escapeHtml)) {
|
1310 | if (this.preserve) {
|
1311 | if (this.cleanValue) {
|
1312 | code = "\#{ $p($c(" + assignment + ")) }";
|
1313 | } else {
|
1314 | code = "\#{ $p(" + assignment + ") }";
|
1315 | }
|
1316 | } else {
|
1317 | if (this.cleanValue) {
|
1318 | code = "\#{ $c(" + assignment + ") }";
|
1319 | } else {
|
1320 | code = "\#{ " + assignment + " }";
|
1321 | }
|
1322 | }
|
1323 | }
|
1324 | this.opener = this.markText("" + prefix + ">" + code);
|
1325 | return this.closer = this.markText("</" + tokens.tag + ">");
|
1326 | } else if (tokens.text) {
|
1327 | this.opener = this.markText("" + prefix + ">" + tokens.text);
|
1328 | return this.closer = this.markText("</" + tokens.tag + ">");
|
1329 | } else {
|
1330 | this.opener = this.markText(prefix + '>');
|
1331 | return this.closer = this.markText("</" + tokens.tag + ">");
|
1332 | }
|
1333 | } else {
|
1334 | tokens.tag = tokens.tag.replace(/\/$/, '');
|
1335 | prefix = this.buildHtmlTagPrefix(tokens);
|
1336 | return this.opener = this.markText("" + prefix + (this.format === 'xhtml' ? ' /' : '') + ">");
|
1337 | }
|
1338 | }
|
1339 | };
|
1340 |
|
1341 | Haml.prototype.parseExpression = function(exp) {
|
1342 | var attributes, classes, id, key, tag, value, _ref1, _ref2;
|
1343 |
|
1344 | tag = this.parseTag(exp);
|
1345 | if (this.preserveTags.indexOf(tag.tag) !== -1) {
|
1346 | this.preserve = true;
|
1347 | }
|
1348 | id = this.interpolateCodeAttribute((_ref1 = tag.ids) != null ? _ref1.pop() : void 0, true);
|
1349 | classes = tag.classes;
|
1350 | attributes = {};
|
1351 | if (tag.attributes) {
|
1352 | _ref2 = tag.attributes;
|
1353 | for (key in _ref2) {
|
1354 | value = _ref2[key];
|
1355 | if (key === 'id') {
|
1356 | if (id) {
|
1357 | id += '_' + this.interpolateCodeAttribute(value, true);
|
1358 | } else {
|
1359 | id = this.interpolateCodeAttribute(value, true);
|
1360 | }
|
1361 | } else if (key === 'class') {
|
1362 | classes || (classes = []);
|
1363 | classes.push(value);
|
1364 | } else {
|
1365 | attributes[key] = value;
|
1366 | }
|
1367 | }
|
1368 | }
|
1369 | return {
|
1370 | doctype: tag.doctype,
|
1371 | tag: tag.tag,
|
1372 | id: id,
|
1373 | classes: classes,
|
1374 | text: escapeQuotes(tag.text),
|
1375 | attributes: attributes,
|
1376 | assignment: tag.assignment,
|
1377 | reference: tag.reference
|
1378 | };
|
1379 | };
|
1380 |
|
1381 | Haml.prototype.parseTag = function(exp) {
|
1382 | var assignment, attr, attributes, ch, classes, doctype, end, error, haml, htmlAttributes, id, ids, key, klass, level, pos, reference, rest, rubyAttributes, start, tag, text, val, whitespace, _i, _j, _k, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5;
|
1383 |
|
1384 | try {
|
1385 | doctype = (_ref1 = exp.match(/^(\!{3}.*)/)) != null ? _ref1[1] : void 0;
|
1386 | if (doctype) {
|
1387 | return {
|
1388 | doctype: doctype
|
1389 | };
|
1390 | }
|
1391 | haml = exp.match(/^((?:[#%\.][a-z0-9_:\-]*[\/]?)+)/i)[0];
|
1392 | rest = exp.substring(haml.length);
|
1393 | if (rest.match(/^[{([]/)) {
|
1394 | reference = '';
|
1395 | htmlAttributes = '';
|
1396 | rubyAttributes = '';
|
1397 | _ref2 = ['[', '{', '(', '[', '{', '('];
|
1398 | for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
1399 | start = _ref2[_i];
|
1400 | if (start === rest[0]) {
|
1401 | end = (function() {
|
1402 | switch (start) {
|
1403 | case '{':
|
1404 | return '}';
|
1405 | case '(':
|
1406 | return ')';
|
1407 | case '[':
|
1408 | return ']';
|
1409 | }
|
1410 | })();
|
1411 | level = 0;
|
1412 | for (pos = _j = 0, _ref3 = rest.length; 0 <= _ref3 ? _j <= _ref3 : _j >= _ref3; pos = 0 <= _ref3 ? ++_j : --_j) {
|
1413 | ch = rest[pos];
|
1414 | if (ch === start) {
|
1415 | level += 1;
|
1416 | }
|
1417 | if (ch === end) {
|
1418 | if (level === 1) {
|
1419 | break;
|
1420 | } else {
|
1421 | level -= 1;
|
1422 | }
|
1423 | }
|
1424 | }
|
1425 | switch (start) {
|
1426 | case '{':
|
1427 | rubyAttributes += rest.substring(0, pos + 1);
|
1428 | rest = rest.substring(pos + 1);
|
1429 | break;
|
1430 | case '(':
|
1431 | htmlAttributes += rest.substring(0, pos + 1);
|
1432 | rest = rest.substring(pos + 1);
|
1433 | break;
|
1434 | case '[':
|
1435 | reference = rest.substring(1, pos);
|
1436 | rest = rest.substring(pos + 1);
|
1437 | }
|
1438 | }
|
1439 | }
|
1440 | assignment = rest || '';
|
1441 | } else {
|
1442 | reference = '';
|
1443 | htmlAttributes = '';
|
1444 | rubyAttributes = '';
|
1445 | assignment = rest;
|
1446 | }
|
1447 | attributes = {};
|
1448 | _ref4 = [this.parseAttributes(htmlAttributes), this.parseAttributes(rubyAttributes)];
|
1449 | for (_k = 0, _len1 = _ref4.length; _k < _len1; _k++) {
|
1450 | attr = _ref4[_k];
|
1451 | for (key in attr) {
|
1452 | val = attr[key];
|
1453 | attributes[key] = val;
|
1454 | }
|
1455 | }
|
1456 | if (whitespace = (_ref5 = assignment.match(/^[<>]{0,2}/)) != null ? _ref5[0] : void 0) {
|
1457 | assignment = assignment.substring(whitespace.length);
|
1458 | }
|
1459 | if (assignment[0] === ' ') {
|
1460 | assignment = assignment.substring(1);
|
1461 | }
|
1462 | if (assignment && !assignment.match(/^(=|!=|&=|~)/)) {
|
1463 | text = assignment.replace(/^ /, '');
|
1464 | assignment = void 0;
|
1465 | }
|
1466 | if (whitespace) {
|
1467 | if (whitespace.indexOf('>') !== -1) {
|
1468 | this.wsRemoval.around = true;
|
1469 | }
|
1470 | if (whitespace.indexOf('<') !== -1) {
|
1471 | this.wsRemoval.inside = true;
|
1472 | this.preserve = true;
|
1473 | }
|
1474 | }
|
1475 | tag = haml.match(/\%([a-z_\-][a-z0-9_:\-]*[\/]?)/i);
|
1476 | ids = haml.match(/\#([a-z_\-][a-z0-9_\-]*)/gi);
|
1477 | classes = haml.match(/\.([a-z0-9_\-]*)/gi);
|
1478 | return {
|
1479 | tag: tag ? tag[1] : 'div',
|
1480 | ids: ids ? (function() {
|
1481 | var _l, _len2, _results;
|
1482 |
|
1483 | _results = [];
|
1484 | for (_l = 0, _len2 = ids.length; _l < _len2; _l++) {
|
1485 | id = ids[_l];
|
1486 | _results.push("'" + (id.substr(1)) + "'");
|
1487 | }
|
1488 | return _results;
|
1489 | })() : void 0,
|
1490 | classes: classes ? (function() {
|
1491 | var _l, _len2, _results;
|
1492 |
|
1493 | _results = [];
|
1494 | for (_l = 0, _len2 = classes.length; _l < _len2; _l++) {
|
1495 | klass = classes[_l];
|
1496 | _results.push("'" + (klass.substr(1)) + "'");
|
1497 | }
|
1498 | return _results;
|
1499 | })() : void 0,
|
1500 | attributes: attributes,
|
1501 | assignment: assignment,
|
1502 | reference: reference,
|
1503 | text: text
|
1504 | };
|
1505 | } catch (_error) {
|
1506 | error = _error;
|
1507 | throw new Error("Unable to parse tag from " + exp + ": " + error);
|
1508 | }
|
1509 | };
|
1510 |
|
1511 | Haml.prototype.parseAttributes = function(exp) {
|
1512 | var attr, attributes, ch, endPos, hasDataAttribute, inDataAttribute, key, keyValue, keys, level, marker, markers, pairs, pos, quote, quoted, start, startPos, type, value, _i, _j, _k, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5;
|
1513 |
|
1514 | attributes = {};
|
1515 | if (exp === void 0) {
|
1516 | return attributes;
|
1517 | }
|
1518 | type = exp.substring(0, 1);
|
1519 | exp = exp.replace(/(=|:|=>)\s*('([^\\']|\\\\|\\')*'|"([^\\"]|\\\\|\\")*")/g, function(match, type, value) {
|
1520 | return type + (value != null ? value.replace(/(:|=|=>)/g, '\u0090$1') : void 0);
|
1521 | });
|
1522 | level = 0;
|
1523 | start = 0;
|
1524 | markers = [];
|
1525 | if (type === '(') {
|
1526 | startPos = 1;
|
1527 | endPos = exp.length - 1;
|
1528 | } else {
|
1529 | startPos = 0;
|
1530 | endPos = exp.length;
|
1531 | }
|
1532 | for (pos = _i = startPos; startPos <= endPos ? _i < endPos : _i > endPos; pos = startPos <= endPos ? ++_i : --_i) {
|
1533 | ch = exp[pos];
|
1534 | if (ch === '(') {
|
1535 | level += 1;
|
1536 | if (level === 1) {
|
1537 | start = pos;
|
1538 | }
|
1539 | }
|
1540 | if (ch === ')') {
|
1541 | if (level === 1) {
|
1542 | if (start !== 0 && pos - start !== 1) {
|
1543 | markers.push({
|
1544 | start: start,
|
1545 | end: pos
|
1546 | });
|
1547 | }
|
1548 | } else {
|
1549 | level -= 1;
|
1550 | }
|
1551 | }
|
1552 | }
|
1553 | _ref1 = markers.reverse();
|
1554 | for (_j = 0, _len = _ref1.length; _j < _len; _j++) {
|
1555 | marker = _ref1[_j];
|
1556 | exp = exp.substring(0, marker.start) + exp.substring(marker.start, marker.end).replace(/(:|=|=>)/g, '\u0090$1') + exp.substring(marker.end);
|
1557 | }
|
1558 | switch (type) {
|
1559 | case '(':
|
1560 | keys = /\(\s*([-\w]+[\w:-]*\w?)\s*=|\s+([-\w]+[\w:-]*\w?)\s*=|\(\s*('\w+[\w:-]*\w?')\s*=|\s+('\w+[\w:-]*\w?')\s*=|\(\s*("\w+[\w:-]*\w?")\s*=|\s+("\w+[\w:-]*\w?")\s*=/g;
|
1561 | break;
|
1562 | case '{':
|
1563 | keys = /[{,]\s*(\w+[\w:-]*\w?)\s*:|[{,]\s*('[-\w]+[\w:-]*\w?')\s*:|[{,]\s*("[-\w]+[\w:-]*\w?")\s*:|[{,]\s*:(\w+[\w:-]*\w?)\s*=>|[{,]\s*:?'([-\w]+[\w:-]*\w?)'\s*=>|[{,]\s*:?"([-\w]+[\w:-]*\w?)"\s*=>/g;
|
1564 | }
|
1565 | pairs = exp.split(keys).filter(Boolean);
|
1566 | inDataAttribute = false;
|
1567 | hasDataAttribute = false;
|
1568 | while (pairs.length) {
|
1569 | keyValue = pairs.splice(0, 2);
|
1570 | if (keyValue.length === 1) {
|
1571 | attr = keyValue[0].replace(/^[\s({]+|[\s)}]+$/g, '');
|
1572 | attributes[attr] = 'true';
|
1573 | } else {
|
1574 | key = (_ref2 = keyValue[0]) != null ? _ref2.replace(/^\s+|\s+$/g, '').replace(/^:/, '') : void 0;
|
1575 | if (quoted = key.match(/^("|')(.*)\1$/)) {
|
1576 | key = quoted[2];
|
1577 | }
|
1578 | value = (_ref3 = keyValue[1]) != null ? _ref3.replace(/^\s+|[\s,]+$/g, '').replace(/\u0090/g, '') : void 0;
|
1579 | if (key === 'data' && !value) {
|
1580 | inDataAttribute = true;
|
1581 | hasDataAttribute = true;
|
1582 | } else if (key && value) {
|
1583 | if (inDataAttribute) {
|
1584 | key = this.hyphenateDataAttrs ? "data-" + (key.replace('_', '-')) : "data-" + key;
|
1585 | if (/}\s*$/.test(value)) {
|
1586 | inDataAttribute = false;
|
1587 | }
|
1588 | }
|
1589 | }
|
1590 | switch (type) {
|
1591 | case '(':
|
1592 | value = value.replace(/^\s+|[\s)]+$/g, '');
|
1593 | quote = (_ref4 = /^(['"])/.exec(value)) != null ? _ref4[1] : void 0;
|
1594 | pos = value.lastIndexOf(quote);
|
1595 | if (pos > 1) {
|
1596 | _ref5 = value.substring(pos + 1).split(' ');
|
1597 | for (_k = 0, _len1 = _ref5.length; _k < _len1; _k++) {
|
1598 | attr = _ref5[_k];
|
1599 | if (attr) {
|
1600 | attributes[attr] = 'true';
|
1601 | }
|
1602 | }
|
1603 | value = value.substring(0, pos + 1);
|
1604 | }
|
1605 | attributes[key] = value;
|
1606 | break;
|
1607 | case '{':
|
1608 | attributes[key] = value.replace(/^\s+|[\s}]+$/g, '');
|
1609 | }
|
1610 | }
|
1611 | }
|
1612 | if (hasDataAttribute) {
|
1613 | delete attributes['data'];
|
1614 | }
|
1615 | return attributes;
|
1616 | };
|
1617 |
|
1618 | Haml.prototype.buildHtmlTagPrefix = function(tokens) {
|
1619 | var classList, classes, hasDynamicClass, key, klass, name, tagParts, value, _i, _len, _ref1;
|
1620 |
|
1621 | tagParts = ["<" + tokens.tag];
|
1622 | if (tokens.classes) {
|
1623 | hasDynamicClass = false;
|
1624 | classList = (function() {
|
1625 | var _i, _len, _ref1, _results;
|
1626 |
|
1627 | _ref1 = tokens.classes;
|
1628 | _results = [];
|
1629 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
1630 | name = _ref1[_i];
|
1631 | name = this.interpolateCodeAttribute(name, true);
|
1632 | if (name.indexOf('#{') !== -1) {
|
1633 | hasDynamicClass = true;
|
1634 | }
|
1635 | _results.push(name);
|
1636 | }
|
1637 | return _results;
|
1638 | }).call(this);
|
1639 | if (hasDynamicClass && classList.length > 1) {
|
1640 | classes = '#{ [';
|
1641 | for (_i = 0, _len = classList.length; _i < _len; _i++) {
|
1642 | klass = classList[_i];
|
1643 | classes += "" + (this.quoteAndEscapeAttributeValue(klass, true)) + ",";
|
1644 | }
|
1645 | classes = classes.substring(0, classes.length - 1) + '].sort().join(\' \').replace(/^\\s+|\\s+$/g, \'\') }';
|
1646 | } else {
|
1647 | classes = classList.sort().join(' ');
|
1648 | }
|
1649 | tagParts.push("class='" + classes + "'");
|
1650 | }
|
1651 | if (tokens.id) {
|
1652 | tagParts.push("id='" + tokens.id + "'");
|
1653 | }
|
1654 | if (tokens.reference) {
|
1655 | if (tokens.attributes) {
|
1656 | delete tokens.attributes['class'];
|
1657 | delete tokens.attributes['id'];
|
1658 | }
|
1659 | tagParts.push("\#{$r(" + tokens.reference + ")}");
|
1660 | }
|
1661 | if (tokens.attributes) {
|
1662 | _ref1 = tokens.attributes;
|
1663 | for (key in _ref1) {
|
1664 | value = _ref1[key];
|
1665 | if (value === 'true' || value === 'false') {
|
1666 | if (value === 'true') {
|
1667 | if (this.format === 'html5') {
|
1668 | tagParts.push("" + key);
|
1669 | } else {
|
1670 | tagParts.push("" + key + "=" + (this.quoteAndEscapeAttributeValue(key)));
|
1671 | }
|
1672 | }
|
1673 | } else {
|
1674 | tagParts.push("" + key + "=" + (this.quoteAndEscapeAttributeValue(this.interpolateCodeAttribute(value))));
|
1675 | }
|
1676 | }
|
1677 | }
|
1678 | return tagParts.join(' ');
|
1679 | };
|
1680 |
|
1681 | Haml.prototype.interpolateCodeAttribute = function(text, unwrap) {
|
1682 | var quoted;
|
1683 |
|
1684 | if (unwrap == null) {
|
1685 | unwrap = false;
|
1686 | }
|
1687 | if (!text) {
|
1688 | return;
|
1689 | }
|
1690 | if (!text.match(/^("|').*\1$/)) {
|
1691 | if (this.escapeAttributes) {
|
1692 | if (this.cleanValue) {
|
1693 | text = '#{ $e($c(' + text + ')) }';
|
1694 | } else {
|
1695 | text = '#{ $e(' + text + ') }';
|
1696 | }
|
1697 | } else {
|
1698 | if (this.cleanValue) {
|
1699 | text = '#{ $c(' + text + ') }';
|
1700 | } else {
|
1701 | text = '#{ (' + text + ') }';
|
1702 | }
|
1703 | }
|
1704 | }
|
1705 | if (unwrap) {
|
1706 | if (quoted = text.match(/^("|')(.*)\1$/)) {
|
1707 | text = quoted[2];
|
1708 | }
|
1709 | }
|
1710 | return text;
|
1711 | };
|
1712 |
|
1713 | Haml.prototype.quoteAndEscapeAttributeValue = function(value, code) {
|
1714 | var escaped, hasDoubleQuotes, hasInterpolation, hasSingleQuotes, quoted, result, token, tokens;
|
1715 |
|
1716 | if (code == null) {
|
1717 | code = false;
|
1718 | }
|
1719 | if (!value) {
|
1720 | return;
|
1721 | }
|
1722 | if (quoted = value.match(/^("|')(.*)\1$/)) {
|
1723 | value = quoted[2];
|
1724 | }
|
1725 | tokens = this.splitInterpolations(value);
|
1726 | hasSingleQuotes = false;
|
1727 | hasDoubleQuotes = false;
|
1728 | hasInterpolation = false;
|
1729 | tokens = (function() {
|
1730 | var _i, _len, _results;
|
1731 |
|
1732 | _results = [];
|
1733 | for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1734 | token = tokens[_i];
|
1735 | if (token.slice(0, 2) === '#{') {
|
1736 | if (token.indexOf('$e') === -1 && token.indexOf('$c') === -1) {
|
1737 | if (this.escapeAttributes) {
|
1738 | if (this.cleanValue) {
|
1739 | token = '#{ $e($c(' + token.slice(2, -1) + ')) }';
|
1740 | } else {
|
1741 | token = '#{ $e(' + token.slice(2, -1) + ') }';
|
1742 | }
|
1743 | } else {
|
1744 | if (this.cleanValue) {
|
1745 | token = '#{ $c(' + token.slice(2, -1) + ') }';
|
1746 | }
|
1747 | }
|
1748 | }
|
1749 | hasInterpolation = true;
|
1750 | } else {
|
1751 | if (!hasSingleQuotes) {
|
1752 | hasSingleQuotes = token.indexOf("'") !== -1;
|
1753 | }
|
1754 | if (!hasDoubleQuotes) {
|
1755 | hasDoubleQuotes = token.indexOf('"') !== -1;
|
1756 | }
|
1757 | }
|
1758 | _results.push(token);
|
1759 | }
|
1760 | return _results;
|
1761 | }).call(this);
|
1762 | if (code) {
|
1763 | if (hasInterpolation) {
|
1764 | result = "\"" + (tokens.join('')) + "\"";
|
1765 | } else {
|
1766 | result = "'" + (tokens.join('')) + "'";
|
1767 | }
|
1768 | } else {
|
1769 | if (!hasDoubleQuotes && !hasSingleQuotes) {
|
1770 | result = "'" + (tokens.join('')) + "'";
|
1771 | }
|
1772 | if (hasSingleQuotes && !hasDoubleQuotes) {
|
1773 | result = "\\\"" + (tokens.join('')) + "\\\"";
|
1774 | }
|
1775 | if (hasDoubleQuotes && !hasSingleQuotes) {
|
1776 | escaped = (function() {
|
1777 | var _i, _len, _results;
|
1778 |
|
1779 | _results = [];
|
1780 | for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1781 | token = tokens[_i];
|
1782 | _results.push(escapeQuotes(token));
|
1783 | }
|
1784 | return _results;
|
1785 | })();
|
1786 | result = "'" + (escaped.join('')) + "'";
|
1787 | }
|
1788 | if (hasSingleQuotes && hasDoubleQuotes) {
|
1789 | escaped = (function() {
|
1790 | var _i, _len, _results;
|
1791 |
|
1792 | _results = [];
|
1793 | for (_i = 0, _len = tokens.length; _i < _len; _i++) {
|
1794 | token = tokens[_i];
|
1795 | _results.push(escapeQuotes(token).replace(/'/g, '''));
|
1796 | }
|
1797 | return _results;
|
1798 | })();
|
1799 | result = "'" + (escaped.join('')) + "'";
|
1800 | }
|
1801 | }
|
1802 | return result;
|
1803 | };
|
1804 |
|
1805 | Haml.prototype.splitInterpolations = function(value) {
|
1806 | var ch, ch2, level, pos, start, tokens, _i, _ref1;
|
1807 |
|
1808 | level = 0;
|
1809 | start = 0;
|
1810 | tokens = [];
|
1811 | for (pos = _i = 0, _ref1 = value.length; 0 <= _ref1 ? _i < _ref1 : _i > _ref1; pos = 0 <= _ref1 ? ++_i : --_i) {
|
1812 | ch = value[pos];
|
1813 | ch2 = value.slice(pos, +(pos + 1) + 1 || 9e9);
|
1814 | if (ch === '{') {
|
1815 | level += 1;
|
1816 | }
|
1817 | if (ch2 === '#{' && level === 0) {
|
1818 | tokens.push(value.slice(start, pos));
|
1819 | start = pos;
|
1820 | }
|
1821 | if (ch === '}') {
|
1822 | level -= 1;
|
1823 | if (level === 0) {
|
1824 | tokens.push(value.slice(start, +pos + 1 || 9e9));
|
1825 | start = pos + 1;
|
1826 | }
|
1827 | }
|
1828 | }
|
1829 | tokens.push(value.slice(start, value.length));
|
1830 | return tokens.filter(Boolean);
|
1831 | };
|
1832 |
|
1833 | Haml.prototype.buildDocType = function(doctype) {
|
1834 | switch ("" + this.format + " " + doctype) {
|
1835 | case 'xhtml !!! XML':
|
1836 | return '<?xml version=\'1.0\' encoding=\'utf-8\' ?>';
|
1837 | case 'xhtml !!!':
|
1838 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
|
1839 | case 'xhtml !!! 1.1':
|
1840 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
|
1841 | case 'xhtml !!! mobile':
|
1842 | return '<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">';
|
1843 | case 'xhtml !!! basic':
|
1844 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">';
|
1845 | case 'xhtml !!! frameset':
|
1846 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
|
1847 | case 'xhtml !!! 5':
|
1848 | case 'html5 !!!':
|
1849 | return '<!DOCTYPE html>';
|
1850 | case 'html5 !!! XML':
|
1851 | case 'html4 !!! XML':
|
1852 | return '';
|
1853 | case 'html4 !!!':
|
1854 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
|
1855 | case 'html4 !!! frameset':
|
1856 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
|
1857 | case 'html4 !!! strict':
|
1858 | return '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">';
|
1859 | }
|
1860 | };
|
1861 |
|
1862 | Haml.prototype.isNotSelfClosing = function(tag) {
|
1863 | return this.selfCloseTags.indexOf(tag) === -1 && !tag.match(/\/$/);
|
1864 | };
|
1865 |
|
1866 | return Haml;
|
1867 |
|
1868 | })(Node);
|
1869 |
|
1870 | }).call(this);
|
1871 |
|
1872 | });
|
1873 |
|
1874 | require.define("/nodes/code.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1875 | var Code, Node, _ref,
|
1876 | __hasProp = {}.hasOwnProperty,
|
1877 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1878 |
|
1879 | Node = require('./node');
|
1880 |
|
1881 | module.exports = Code = (function(_super) {
|
1882 | __extends(Code, _super);
|
1883 |
|
1884 | function Code() {
|
1885 | _ref = Code.__super__.constructor.apply(this, arguments);
|
1886 | return _ref;
|
1887 | }
|
1888 |
|
1889 | Code.prototype.evaluate = function() {
|
1890 | var code, codeBlock, escape, identifier;
|
1891 |
|
1892 | codeBlock = this.expression.match(/(-|!=|\&=|=|~)\s?(.*)?/);
|
1893 | identifier = codeBlock[1];
|
1894 | code = codeBlock[2];
|
1895 | if (identifier === '-') {
|
1896 | this.opener = this.markRunningCode(code);
|
1897 | if (this.children.length !== 0 && this.opener.code.match(/(->|=>)/)) {
|
1898 | return this.closer = this.markRunningCode(" ''");
|
1899 | }
|
1900 | } else if (identifier === '~') {
|
1901 | if (this.escapeHtml) {
|
1902 | return this.opener = this.markInsertingCode(code, true, false, true);
|
1903 | } else {
|
1904 | return this.opener = this.markInsertingCode(code, false, false, true);
|
1905 | }
|
1906 | } else {
|
1907 | escape = identifier === '&=' || (identifier === '=' && this.escapeHtml);
|
1908 | if (this.children.length !== 0 && code.match(/(->|=>)$/)) {
|
1909 | this.opener = this.markInsertingCode(code, escape, false, false);
|
1910 | this.opener.block = 'start';
|
1911 | this.closer = this.markRunningCode(" $buffer.join \"\\n\"");
|
1912 | return this.closer.block = 'end';
|
1913 | } else {
|
1914 | return this.opener = this.markInsertingCode(code, escape);
|
1915 | }
|
1916 | }
|
1917 | };
|
1918 |
|
1919 | return Code;
|
1920 |
|
1921 | })(Node);
|
1922 |
|
1923 | }).call(this);
|
1924 |
|
1925 | });
|
1926 |
|
1927 | require.define("/nodes/comment.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1928 | var Comment, Node, escapeQuotes, _ref,
|
1929 | __hasProp = {}.hasOwnProperty,
|
1930 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1931 |
|
1932 | Node = require('./node');
|
1933 |
|
1934 | escapeQuotes = require('../util/text').escapeQuotes;
|
1935 |
|
1936 | module.exports = Comment = (function(_super) {
|
1937 | __extends(Comment, _super);
|
1938 |
|
1939 | function Comment() {
|
1940 | _ref = Comment.__super__.constructor.apply(this, arguments);
|
1941 | return _ref;
|
1942 | }
|
1943 |
|
1944 | Comment.prototype.evaluate = function() {
|
1945 | var comment, expression, identifier, _ref1;
|
1946 |
|
1947 | _ref1 = this.expression.match(/(-#|\/\[|\/)\s?(.*)?/), expression = _ref1[0], identifier = _ref1[1], comment = _ref1[2];
|
1948 | switch (identifier) {
|
1949 | case '-#':
|
1950 | this.silent = true;
|
1951 | return this.opener = this.markText('');
|
1952 | case '\/[':
|
1953 | this.opener = this.markText("<!--[" + comment + ">");
|
1954 | return this.closer = this.markText('<![endif]-->');
|
1955 | case '\/':
|
1956 | if (comment) {
|
1957 | this.opener = this.markText("<!-- " + (escapeQuotes(comment)));
|
1958 | return this.closer = this.markText(' -->');
|
1959 | } else {
|
1960 | this.opener = this.markText("<!--");
|
1961 | return this.closer = this.markText('-->');
|
1962 | }
|
1963 | }
|
1964 | };
|
1965 |
|
1966 | return Comment;
|
1967 |
|
1968 | })(Node);
|
1969 |
|
1970 | }).call(this);
|
1971 |
|
1972 | });
|
1973 |
|
1974 | require.define("/nodes/filter.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
1975 | var Filter, Node, unescapeQuotes, whitespace, _ref,
|
1976 | __hasProp = {}.hasOwnProperty,
|
1977 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
1978 |
|
1979 | Node = require('./node');
|
1980 |
|
1981 | whitespace = require('../util/text').whitespace;
|
1982 |
|
1983 | unescapeQuotes = require('../util/text').unescapeQuotes;
|
1984 |
|
1985 | module.exports = Filter = (function(_super) {
|
1986 | __extends(Filter, _super);
|
1987 |
|
1988 | function Filter() {
|
1989 | _ref = Filter.__super__.constructor.apply(this, arguments);
|
1990 | return _ref;
|
1991 | }
|
1992 |
|
1993 | Filter.prototype.evaluate = function() {
|
1994 | var _ref1;
|
1995 |
|
1996 | return this.filter = (_ref1 = this.expression.match(/:(escaped|preserve|css|javascript|coffeescript|plain|cdata|coffeescript)(.*)?/)) != null ? _ref1[1] : void 0;
|
1997 | };
|
1998 |
|
1999 | Filter.prototype.render = function() {
|
2000 | var child, indent, output, preserve, _i, _j, _len, _len1, _ref1, _ref2;
|
2001 |
|
2002 | output = [];
|
2003 | switch (this.filter) {
|
2004 | case 'escaped':
|
2005 | _ref1 = this.children;
|
2006 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
2007 | child = _ref1[_i];
|
2008 | output.push(this.markText(child.render()[0].text, true));
|
2009 | }
|
2010 | break;
|
2011 | case 'preserve':
|
2012 | preserve = '';
|
2013 | _ref2 = this.children;
|
2014 | for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
2015 | child = _ref2[_j];
|
2016 | preserve += "" + (child.render()[0].text) + "
";
|
2017 | }
|
2018 | preserve = preserve.replace(/\&\#x000A;$/, '');
|
2019 | output.push(this.markText(preserve));
|
2020 | break;
|
2021 | case 'plain':
|
2022 | this.renderFilterContent(0, output);
|
2023 | break;
|
2024 | case 'css':
|
2025 | if (this.format === 'html5') {
|
2026 | output.push(this.markText('<style>'));
|
2027 | } else {
|
2028 | output.push(this.markText('<style type=\'text/css\'>'));
|
2029 | }
|
2030 | if (this.format === 'xhtml') {
|
2031 | output.push(this.markText(' /*<![CDATA[*/'));
|
2032 | }
|
2033 | indent = this.format === 'xhtml' ? 2 : 1;
|
2034 | this.renderFilterContent(indent, output);
|
2035 | if (this.format === 'xhtml') {
|
2036 | output.push(this.markText(' /*]]>*/'));
|
2037 | }
|
2038 | output.push(this.markText('</style>'));
|
2039 | break;
|
2040 | case 'javascript':
|
2041 | if (this.format === 'html5') {
|
2042 | output.push(this.markText('<script>'));
|
2043 | } else {
|
2044 | output.push(this.markText('<script type=\'text/javascript\'>'));
|
2045 | }
|
2046 | if (this.format === 'xhtml') {
|
2047 | output.push(this.markText(' //<![CDATA['));
|
2048 | }
|
2049 | indent = this.format === 'xhtml' ? 2 : 1;
|
2050 | this.renderFilterContent(indent, output);
|
2051 | if (this.format === 'xhtml') {
|
2052 | output.push(this.markText(' //]]>'));
|
2053 | }
|
2054 | output.push(this.markText('</script>'));
|
2055 | break;
|
2056 | case 'cdata':
|
2057 | output.push(this.markText('<![CDATA['));
|
2058 | this.renderFilterContent(2, output);
|
2059 | output.push(this.markText(']]>'));
|
2060 | break;
|
2061 | case 'coffeescript':
|
2062 | this.renderFilterContent(0, output, 'run');
|
2063 | }
|
2064 | return output;
|
2065 | };
|
2066 |
|
2067 | Filter.prototype.renderFilterContent = function(indent, output, type) {
|
2068 | var child, content, e, empty, line, _i, _j, _k, _len, _len1, _ref1, _results;
|
2069 |
|
2070 | if (type == null) {
|
2071 | type = 'text';
|
2072 | }
|
2073 | content = [];
|
2074 | empty = 0;
|
2075 | _ref1 = this.children;
|
2076 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
2077 | child = _ref1[_i];
|
2078 | content.push(child.render()[0].text);
|
2079 | }
|
2080 | _results = [];
|
2081 | for (_j = 0, _len1 = content.length; _j < _len1; _j++) {
|
2082 | line = content[_j];
|
2083 | if (line === '') {
|
2084 | _results.push(empty += 1);
|
2085 | } else {
|
2086 | switch (type) {
|
2087 | case 'text':
|
2088 | for (e = _k = 0; 0 <= empty ? _k < empty : _k > empty; e = 0 <= empty ? ++_k : --_k) {
|
2089 | output.push(this.markText(""));
|
2090 | }
|
2091 | output.push(this.markText("" + (whitespace(indent)) + line));
|
2092 | break;
|
2093 | case 'run':
|
2094 | output.push(this.markRunningCode("" + (unescapeQuotes(line))));
|
2095 | }
|
2096 | _results.push(empty = 0);
|
2097 | }
|
2098 | }
|
2099 | return _results;
|
2100 | };
|
2101 |
|
2102 | return Filter;
|
2103 |
|
2104 | })(Node);
|
2105 |
|
2106 | }).call(this);
|
2107 |
|
2108 | });
|
2109 |
|
2110 | require.define("/nodes/directive.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
2111 | var Directive, Node, path, _ref,
|
2112 | __hasProp = {}.hasOwnProperty,
|
2113 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
2114 |
|
2115 | path = require('path');
|
2116 |
|
2117 | Node = require('./node');
|
2118 |
|
2119 | module.exports = Directive = (function(_super) {
|
2120 | __extends(Directive, _super);
|
2121 |
|
2122 | function Directive() {
|
2123 | _ref = Directive.__super__.constructor.apply(this, arguments);
|
2124 | return _ref;
|
2125 | }
|
2126 |
|
2127 | Directive.prototype.directives = {
|
2128 | include: function(expression) {
|
2129 | var context, e, name, statement, _ref1;
|
2130 |
|
2131 | try {
|
2132 | _ref1 = expression.match(/\s*['"](.*)['"](?:,\s*(.*))?\s*/), _ref1[0], name = _ref1[1], context = _ref1[2];
|
2133 | } catch (_error) {
|
2134 | e = _error;
|
2135 | throw new Error("Failed to parse the include directive from " + expression);
|
2136 | }
|
2137 | if (!context) {
|
2138 | context = 'this';
|
2139 | }
|
2140 | statement = (function() {
|
2141 | switch (this.placement) {
|
2142 | case 'global':
|
2143 | return "" + this.namespace + "['" + name + "'].apply(" + context + ")";
|
2144 | case 'amd':
|
2145 | return "require('" + name + "').apply(" + context + ")";
|
2146 | default:
|
2147 | throw new Error("Include directive not available when placement is " + this.placement);
|
2148 | }
|
2149 | }).call(this);
|
2150 | return this.opener = this.markInsertingCode(statement, false);
|
2151 | }
|
2152 | };
|
2153 |
|
2154 | Directive.prototype.evaluate = function() {
|
2155 | var directives, e, name, rest, _ref1;
|
2156 |
|
2157 | directives = Object.keys(this.directives).join('|');
|
2158 | try {
|
2159 | _ref1 = this.expression.match(RegExp("\\+(" + directives + ")(.*)")), _ref1[0], name = _ref1[1], rest = _ref1[2];
|
2160 | } catch (_error) {
|
2161 | e = _error;
|
2162 | throw new Error("Unable to recognize directive from " + this.expression);
|
2163 | }
|
2164 | return this.directives[name].call(this, rest);
|
2165 | };
|
2166 |
|
2167 | return Directive;
|
2168 |
|
2169 | })(Node);
|
2170 |
|
2171 | }).call(this);
|
2172 |
|
2173 | });
|
2174 |
|
2175 | require.define("/hamlc.coffee",function(require,module,exports,__dirname,__filename,process,global){(function() {
|
2176 | var CoffeeScript, Compiler, fs, __expressCache;
|
2177 |
|
2178 | fs = require('fs');
|
2179 |
|
2180 | Compiler = require('./haml-coffee');
|
2181 |
|
2182 | if (process.browser) {
|
2183 | CoffeeScript = window.CoffeeScript;
|
2184 | } else {
|
2185 | CoffeeScript = require('coffee-script');
|
2186 | }
|
2187 |
|
2188 | __expressCache = {};
|
2189 |
|
2190 | module.exports = {
|
2191 | compile: function(source, options) {
|
2192 | var compiler, template;
|
2193 |
|
2194 | if (options == null) {
|
2195 | options = {};
|
2196 | }
|
2197 | compiler = new Compiler(options);
|
2198 | compiler.parse(source);
|
2199 | template = new Function(CoffeeScript.compile(compiler.precompile(), {
|
2200 | bare: true
|
2201 | }));
|
2202 | return function(params) {
|
2203 | return template.call(params);
|
2204 | };
|
2205 | },
|
2206 | template: function(source, name, namespace, options) {
|
2207 | var compiler;
|
2208 |
|
2209 | if (options == null) {
|
2210 | options = {};
|
2211 | }
|
2212 | options.namespace = namespace;
|
2213 | options.name = name;
|
2214 | compiler = new Compiler(options);
|
2215 | compiler.parse(source);
|
2216 | return CoffeeScript.compile(compiler.render());
|
2217 | },
|
2218 | __express: function(filename, options, callback) {
|
2219 | var err, source;
|
2220 |
|
2221 | if (!!(options && options.constructor && options.call && options.apply)) {
|
2222 | callback = options;
|
2223 | options = {};
|
2224 | }
|
2225 | try {
|
2226 | if (options.cache && __expressCache[filename]) {
|
2227 | return callback(null, __expressCache[filename](options));
|
2228 | } else {
|
2229 | options.filename = filename;
|
2230 | source = fs.readFileSync(filename, 'utf8');
|
2231 | if (options.cache) {
|
2232 | __expressCache[filename] = module.exports.compile(source, options);
|
2233 | return callback(null, __expressCache[filename](options));
|
2234 | } else {
|
2235 | return callback(null, module.exports.compile(source, options)(options));
|
2236 | }
|
2237 | }
|
2238 | } catch (_error) {
|
2239 | err = _error;
|
2240 | return callback(err);
|
2241 | }
|
2242 | }
|
2243 | };
|
2244 |
|
2245 | }).call(this);
|
2246 |
|
2247 | });
|
2248 |
|
2249 | require.define("fs",function(require,module,exports,__dirname,__filename,process,global){
|
2250 |
|
2251 | });
|