1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ejs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | 'use strict';
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | var fs = require('fs');
|
49 | var path = require('path');
|
50 | var utils = require('./utils');
|
51 |
|
52 | var scopeOptionWarned = false;
|
53 | var _VERSION_STRING = require('../package.json').version;
|
54 | var _DEFAULT_OPEN_DELIMITER = '<';
|
55 | var _DEFAULT_CLOSE_DELIMITER = '>';
|
56 | var _DEFAULT_DELIMITER = '%';
|
57 | var _DEFAULT_LOCALS_NAME = 'locals';
|
58 | var _NAME = 'ejs';
|
59 | var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';
|
60 | var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',
|
61 | 'client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];
|
62 |
|
63 |
|
64 |
|
65 | var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
|
66 | var _BOM = /^\uFEFF/;
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | exports.cache = utils.cache;
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | exports.fileLoader = fs.readFileSync;
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | exports.localsName = _DEFAULT_LOCALS_NAME;
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | exports.promiseImpl = (new Function('return this;'))().Promise;
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | exports.resolveInclude = function(name, filename, isDir) {
|
119 | var dirname = path.dirname;
|
120 | var extname = path.extname;
|
121 | var resolve = path.resolve;
|
122 | var includePath = resolve(isDir ? filename : dirname(filename), name);
|
123 | var ext = extname(name);
|
124 | if (!ext) {
|
125 | includePath += '.ejs';
|
126 | }
|
127 | return includePath;
|
128 | };
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | function getIncludePath(path, options) {
|
138 | var includePath;
|
139 | var filePath;
|
140 | var views = options.views;
|
141 | var match = /^[A-Za-z]+:\\|^\//.exec(path);
|
142 |
|
143 |
|
144 | if (match && match.length) {
|
145 | includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
|
146 | }
|
147 |
|
148 | else {
|
149 |
|
150 | if (options.filename) {
|
151 | filePath = exports.resolveInclude(path, options.filename);
|
152 | if (fs.existsSync(filePath)) {
|
153 | includePath = filePath;
|
154 | }
|
155 | }
|
156 |
|
157 | if (!includePath) {
|
158 | if (Array.isArray(views) && views.some(function (v) {
|
159 | filePath = exports.resolveInclude(path, v, true);
|
160 | return fs.existsSync(filePath);
|
161 | })) {
|
162 | includePath = filePath;
|
163 | }
|
164 | }
|
165 | if (!includePath) {
|
166 | throw new Error('Could not find the include file "' +
|
167 | options.escapeFunction(path) + '"');
|
168 | }
|
169 | }
|
170 | return includePath;
|
171 | }
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 | function handleCache(options, template) {
|
192 | var func;
|
193 | var filename = options.filename;
|
194 | var hasTemplate = arguments.length > 1;
|
195 |
|
196 | if (options.cache) {
|
197 | if (!filename) {
|
198 | throw new Error('cache option requires a filename');
|
199 | }
|
200 | func = exports.cache.get(filename);
|
201 | if (func) {
|
202 | return func;
|
203 | }
|
204 | if (!hasTemplate) {
|
205 | template = fileLoader(filename).toString().replace(_BOM, '');
|
206 | }
|
207 | }
|
208 | else if (!hasTemplate) {
|
209 |
|
210 | if (!filename) {
|
211 | throw new Error('Internal EJS error: no file name or template '
|
212 | + 'provided');
|
213 | }
|
214 | template = fileLoader(filename).toString().replace(_BOM, '');
|
215 | }
|
216 | func = exports.compile(template, options);
|
217 | if (options.cache) {
|
218 | exports.cache.set(filename, func);
|
219 | }
|
220 | return func;
|
221 | }
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 |
|
235 | function tryHandleCache(options, data, cb) {
|
236 | var result;
|
237 | if (!cb) {
|
238 | if (typeof exports.promiseImpl == 'function') {
|
239 | return new exports.promiseImpl(function (resolve, reject) {
|
240 | try {
|
241 | result = handleCache(options)(data);
|
242 | resolve(result);
|
243 | }
|
244 | catch (err) {
|
245 | reject(err);
|
246 | }
|
247 | });
|
248 | }
|
249 | else {
|
250 | throw new Error('Please provide a callback function');
|
251 | }
|
252 | }
|
253 | else {
|
254 | try {
|
255 | result = handleCache(options)(data);
|
256 | }
|
257 | catch (err) {
|
258 | return cb(err);
|
259 | }
|
260 |
|
261 | cb(null, result);
|
262 | }
|
263 | }
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 | function fileLoader(filePath){
|
274 | return exports.fileLoader(filePath);
|
275 | }
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 | function includeFile(path, options) {
|
291 | var opts = utils.shallowCopy({}, options);
|
292 | opts.filename = getIncludePath(path, opts);
|
293 | return handleCache(opts);
|
294 | }
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 | function includeSource(path, options) {
|
307 | var opts = utils.shallowCopy({}, options);
|
308 | var includePath;
|
309 | var template;
|
310 | includePath = getIncludePath(path, opts);
|
311 | template = fileLoader(includePath).toString().replace(_BOM, '');
|
312 | opts.filename = includePath;
|
313 | var templ = new Template(template, opts);
|
314 | templ.generateSource();
|
315 | return {
|
316 | source: templ.source,
|
317 | filename: includePath,
|
318 | template: template
|
319 | };
|
320 | }
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 | function rethrow(err, str, flnm, lineno, esc){
|
336 | var lines = str.split('\n');
|
337 | var start = Math.max(lineno - 3, 0);
|
338 | var end = Math.min(lines.length, lineno + 3);
|
339 | var filename = esc(flnm);
|
340 |
|
341 | var context = lines.slice(start, end).map(function (line, i){
|
342 | var curr = i + start + 1;
|
343 | return (curr == lineno ? ' >> ' : ' ')
|
344 | + curr
|
345 | + '| '
|
346 | + line;
|
347 | }).join('\n');
|
348 |
|
349 |
|
350 | err.path = filename;
|
351 | err.message = (filename || 'ejs') + ':'
|
352 | + lineno + '\n'
|
353 | + context + '\n\n'
|
354 | + err.message;
|
355 |
|
356 | throw err;
|
357 | }
|
358 |
|
359 | function stripSemi(str){
|
360 | return str.replace(/;(\s*$)/, '$1');
|
361 | }
|
362 |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 | exports.compile = function compile(template, opts) {
|
377 | var templ;
|
378 |
|
379 |
|
380 |
|
381 |
|
382 | if (opts && opts.scope) {
|
383 | if (!scopeOptionWarned){
|
384 | console.warn('`scope` option is deprecated and will be removed in EJS 3');
|
385 | scopeOptionWarned = true;
|
386 | }
|
387 | if (!opts.context) {
|
388 | opts.context = opts.scope;
|
389 | }
|
390 | delete opts.scope;
|
391 | }
|
392 | templ = new Template(template, opts);
|
393 | return templ.compile();
|
394 | };
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 | exports.render = function (template, d, o) {
|
411 | var data = d || {};
|
412 | var opts = o || {};
|
413 |
|
414 |
|
415 |
|
416 | if (arguments.length == 2) {
|
417 | utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
|
418 | }
|
419 |
|
420 | return handleCache(opts, template)(data);
|
421 | };
|
422 |
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 |
|
436 | exports.renderFile = function () {
|
437 | var args = Array.prototype.slice.call(arguments);
|
438 | var filename = args.shift();
|
439 | var cb;
|
440 | var opts = {filename: filename};
|
441 | var data;
|
442 | var viewOpts;
|
443 |
|
444 |
|
445 | if (typeof arguments[arguments.length - 1] == 'function') {
|
446 | cb = args.pop();
|
447 | }
|
448 |
|
449 | if (args.length) {
|
450 |
|
451 | data = args.shift();
|
452 |
|
453 | if (args.length) {
|
454 |
|
455 | utils.shallowCopy(opts, args.pop());
|
456 | }
|
457 |
|
458 | else {
|
459 |
|
460 | if (data.settings) {
|
461 |
|
462 | if (data.settings.views) {
|
463 | opts.views = data.settings.views;
|
464 | }
|
465 | if (data.settings['view cache']) {
|
466 | opts.cache = true;
|
467 | }
|
468 |
|
469 |
|
470 | viewOpts = data.settings['view options'];
|
471 | if (viewOpts) {
|
472 | utils.shallowCopy(opts, viewOpts);
|
473 | }
|
474 | }
|
475 |
|
476 |
|
477 |
|
478 | utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
|
479 | }
|
480 | opts.filename = filename;
|
481 | }
|
482 | else {
|
483 | data = {};
|
484 | }
|
485 |
|
486 | return tryHandleCache(opts, data, cb);
|
487 | };
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 | exports.Template = Template;
|
499 |
|
500 | exports.clearCache = function () {
|
501 | exports.cache.reset();
|
502 | };
|
503 |
|
504 | function Template(text, opts) {
|
505 | opts = opts || {};
|
506 | var options = {};
|
507 | this.templateText = text;
|
508 | this.mode = null;
|
509 | this.truncate = false;
|
510 | this.currentLine = 1;
|
511 | this.source = '';
|
512 | this.dependencies = [];
|
513 | options.client = opts.client || false;
|
514 | options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
|
515 | options.compileDebug = opts.compileDebug !== false;
|
516 | options.debug = !!opts.debug;
|
517 | options.filename = opts.filename;
|
518 | options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
|
519 | options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
|
520 | options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
|
521 | options.strict = opts.strict || false;
|
522 | options.context = opts.context;
|
523 | options.cache = opts.cache || false;
|
524 | options.rmWhitespace = opts.rmWhitespace;
|
525 | options.root = opts.root;
|
526 | options.outputFunctionName = opts.outputFunctionName;
|
527 | options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
|
528 | options.views = opts.views;
|
529 | options.async = opts.async;
|
530 | options.destructuredLocals = opts.destructuredLocals;
|
531 | options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;
|
532 |
|
533 | if (options.strict) {
|
534 | options._with = false;
|
535 | }
|
536 | else {
|
537 | options._with = typeof opts._with != 'undefined' ? opts._with : true;
|
538 | }
|
539 |
|
540 | this.opts = options;
|
541 |
|
542 | this.regex = this.createRegex();
|
543 | }
|
544 |
|
545 | Template.modes = {
|
546 | EVAL: 'eval',
|
547 | ESCAPED: 'escaped',
|
548 | RAW: 'raw',
|
549 | COMMENT: 'comment',
|
550 | LITERAL: 'literal'
|
551 | };
|
552 |
|
553 | Template.prototype = {
|
554 | createRegex: function () {
|
555 | var str = _REGEX_STRING;
|
556 | var delim = utils.escapeRegExpChars(this.opts.delimiter);
|
557 | var open = utils.escapeRegExpChars(this.opts.openDelimiter);
|
558 | var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
|
559 | str = str.replace(/%/g, delim)
|
560 | .replace(/</g, open)
|
561 | .replace(/>/g, close);
|
562 | return new RegExp(str);
|
563 | },
|
564 |
|
565 | compile: function () {
|
566 | var src;
|
567 | var fn;
|
568 | var opts = this.opts;
|
569 | var prepended = '';
|
570 | var appended = '';
|
571 | var escapeFn = opts.escapeFunction;
|
572 | var ctor;
|
573 |
|
574 | if (!this.source) {
|
575 | this.generateSource();
|
576 | prepended +=
|
577 | ' var __output = "";\n' +
|
578 | ' function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
|
579 | if (opts.outputFunctionName) {
|
580 | prepended += ' var ' + opts.outputFunctionName + ' = __append;' + '\n';
|
581 | }
|
582 | if (opts.destructuredLocals && opts.destructuredLocals.length) {
|
583 | var destructuring = ' var __locals = (' + opts.localsName + ' || {}),\n';
|
584 | for (var i = 0; i < opts.destructuredLocals.length; i++) {
|
585 | var name = opts.destructuredLocals[i];
|
586 | if (i > 0) {
|
587 | destructuring += ',\n ';
|
588 | }
|
589 | destructuring += name + ' = __locals.' + name;
|
590 | }
|
591 | prepended += destructuring + ';\n';
|
592 | }
|
593 | if (opts._with !== false) {
|
594 | prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
|
595 | appended += ' }' + '\n';
|
596 | }
|
597 | appended += ' return __output;' + '\n';
|
598 | this.source = prepended + this.source + appended;
|
599 | }
|
600 |
|
601 | if (opts.compileDebug) {
|
602 | src = 'var __line = 1' + '\n'
|
603 | + ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
|
604 | + ' , __filename = ' + (opts.filename ?
|
605 | JSON.stringify(opts.filename) : 'undefined') + ';' + '\n'
|
606 | + 'try {' + '\n'
|
607 | + this.source
|
608 | + '} catch (e) {' + '\n'
|
609 | + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
|
610 | + '}' + '\n';
|
611 | }
|
612 | else {
|
613 | src = this.source;
|
614 | }
|
615 |
|
616 | if (opts.client) {
|
617 | src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
|
618 | if (opts.compileDebug) {
|
619 | src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
|
620 | }
|
621 | }
|
622 |
|
623 | if (opts.strict) {
|
624 | src = '"use strict";\n' + src;
|
625 | }
|
626 | if (opts.debug) {
|
627 | console.log(src);
|
628 | }
|
629 | if (opts.compileDebug && opts.filename) {
|
630 | src = src + '\n'
|
631 | + '//# sourceURL=' + opts.filename + '\n';
|
632 | }
|
633 |
|
634 | try {
|
635 | if (opts.async) {
|
636 |
|
637 |
|
638 | try {
|
639 | ctor = (new Function('return (async function(){}).constructor;'))();
|
640 | }
|
641 | catch(e) {
|
642 | if (e instanceof SyntaxError) {
|
643 | throw new Error('This environment does not support async/await');
|
644 | }
|
645 | else {
|
646 | throw e;
|
647 | }
|
648 | }
|
649 | }
|
650 | else {
|
651 | ctor = Function;
|
652 | }
|
653 | fn = new ctor(opts.localsName + ', escapeFn, include, rethrow', src);
|
654 | }
|
655 | catch(e) {
|
656 |
|
657 | if (e instanceof SyntaxError) {
|
658 | if (opts.filename) {
|
659 | e.message += ' in ' + opts.filename;
|
660 | }
|
661 | e.message += ' while compiling ejs\n\n';
|
662 | e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';
|
663 | e.message += 'https://github.com/RyanZim/EJS-Lint';
|
664 | if (!opts.async) {
|
665 | e.message += '\n';
|
666 | e.message += 'Or, if you meant to create an async function, pass `async: true` as an option.';
|
667 | }
|
668 | }
|
669 | throw e;
|
670 | }
|
671 |
|
672 |
|
673 |
|
674 |
|
675 | var returnedFn = opts.client ? fn : function anonymous(data) {
|
676 | var include = function (path, includeData) {
|
677 | var d = utils.shallowCopy({}, data);
|
678 | if (includeData) {
|
679 | d = utils.shallowCopy(d, includeData);
|
680 | }
|
681 | return includeFile(path, opts)(d);
|
682 | };
|
683 | return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
|
684 | };
|
685 | returnedFn.dependencies = this.dependencies;
|
686 | if (opts.filename && typeof Object.defineProperty === 'function') {
|
687 | var filename = opts.filename;
|
688 | var basename = path.basename(filename, path.extname(filename));
|
689 | try {
|
690 | Object.defineProperty(returnedFn, 'name', {
|
691 | value: basename,
|
692 | writable: false,
|
693 | enumerable: false,
|
694 | configurable: true
|
695 | });
|
696 | } catch (e) {}
|
697 | }
|
698 | return returnedFn;
|
699 | },
|
700 |
|
701 | generateSource: function () {
|
702 | var opts = this.opts;
|
703 |
|
704 | if (opts.rmWhitespace) {
|
705 |
|
706 |
|
707 | this.templateText =
|
708 | this.templateText.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
709 | }
|
710 |
|
711 |
|
712 | this.templateText =
|
713 | this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
|
714 |
|
715 | var self = this;
|
716 | var matches = this.parseTemplateText();
|
717 | var d = this.opts.delimiter;
|
718 | var o = this.opts.openDelimiter;
|
719 | var c = this.opts.closeDelimiter;
|
720 |
|
721 | if (matches && matches.length) {
|
722 | matches.forEach(function (line, index) {
|
723 | var opening;
|
724 | var closing;
|
725 | var include;
|
726 | var includeOpts;
|
727 | var includeObj;
|
728 | var includeSrc;
|
729 |
|
730 |
|
731 |
|
732 |
|
733 | if ( line.indexOf(o + d) === 0
|
734 | && line.indexOf(o + d + d) !== 0) {
|
735 | closing = matches[index + 2];
|
736 | if (!(closing == d + c || closing == '-' + d + c || closing == '_' + d + c)) {
|
737 | throw new Error('Could not find matching close tag for "' + line + '".');
|
738 | }
|
739 | }
|
740 |
|
741 | if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
|
742 | opening = matches[index - 1];
|
743 |
|
744 | if (opening && (opening == o + d || opening == o + d + '-' || opening == o + d + '_')) {
|
745 | includeOpts = utils.shallowCopy({}, self.opts);
|
746 | includeObj = includeSource(include[1], includeOpts);
|
747 | if (self.opts.compileDebug) {
|
748 | includeSrc =
|
749 | ' ; (function(){' + '\n'
|
750 | + ' var __line = 1' + '\n'
|
751 | + ' , __lines = ' + JSON.stringify(includeObj.template) + '\n'
|
752 | + ' , __filename = ' + JSON.stringify(includeObj.filename) + ';' + '\n'
|
753 | + ' try {' + '\n'
|
754 | + includeObj.source
|
755 | + ' } catch (e) {' + '\n'
|
756 | + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
|
757 | + ' }' + '\n'
|
758 | + ' ; }).call(this)' + '\n';
|
759 | }else{
|
760 | includeSrc = ' ; (function(){' + '\n' + includeObj.source +
|
761 | ' ; }).call(this)' + '\n';
|
762 | }
|
763 | self.source += includeSrc;
|
764 | self.dependencies.push(exports.resolveInclude(include[1],
|
765 | includeOpts.filename));
|
766 | return;
|
767 | }
|
768 | }
|
769 | self.scanLine(line);
|
770 | });
|
771 | }
|
772 |
|
773 | },
|
774 |
|
775 | parseTemplateText: function () {
|
776 | var str = this.templateText;
|
777 | var pat = this.regex;
|
778 | var result = pat.exec(str);
|
779 | var arr = [];
|
780 | var firstPos;
|
781 |
|
782 | while (result) {
|
783 | firstPos = result.index;
|
784 |
|
785 | if (firstPos !== 0) {
|
786 | arr.push(str.substring(0, firstPos));
|
787 | str = str.slice(firstPos);
|
788 | }
|
789 |
|
790 | arr.push(result[0]);
|
791 | str = str.slice(result[0].length);
|
792 | result = pat.exec(str);
|
793 | }
|
794 |
|
795 | if (str) {
|
796 | arr.push(str);
|
797 | }
|
798 |
|
799 | return arr;
|
800 | },
|
801 |
|
802 | _addOutput: function (line) {
|
803 | if (this.truncate) {
|
804 |
|
805 |
|
806 |
|
807 |
|
808 |
|
809 | line = line.replace(/^(?:\r\n|\r|\n)/, '');
|
810 | this.truncate = false;
|
811 | }
|
812 | if (!line) {
|
813 | return line;
|
814 | }
|
815 |
|
816 |
|
817 | line = line.replace(/\\/g, '\\\\');
|
818 |
|
819 |
|
820 | line = line.replace(/\n/g, '\\n');
|
821 | line = line.replace(/\r/g, '\\r');
|
822 |
|
823 |
|
824 |
|
825 | line = line.replace(/"/g, '\\"');
|
826 | this.source += ' ; __append("' + line + '")' + '\n';
|
827 | },
|
828 |
|
829 | scanLine: function (line) {
|
830 | var self = this;
|
831 | var d = this.opts.delimiter;
|
832 | var o = this.opts.openDelimiter;
|
833 | var c = this.opts.closeDelimiter;
|
834 | var newLineCount = 0;
|
835 |
|
836 | newLineCount = (line.split('\n').length - 1);
|
837 |
|
838 | switch (line) {
|
839 | case o + d:
|
840 | case o + d + '_':
|
841 | this.mode = Template.modes.EVAL;
|
842 | break;
|
843 | case o + d + '=':
|
844 | this.mode = Template.modes.ESCAPED;
|
845 | break;
|
846 | case o + d + '-':
|
847 | this.mode = Template.modes.RAW;
|
848 | break;
|
849 | case o + d + '#':
|
850 | this.mode = Template.modes.COMMENT;
|
851 | break;
|
852 | case o + d + d:
|
853 | this.mode = Template.modes.LITERAL;
|
854 | this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + '\n';
|
855 | break;
|
856 | case d + d + c:
|
857 | this.mode = Template.modes.LITERAL;
|
858 | this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + '\n';
|
859 | break;
|
860 | case d + c:
|
861 | case '-' + d + c:
|
862 | case '_' + d + c:
|
863 | if (this.mode == Template.modes.LITERAL) {
|
864 | this._addOutput(line);
|
865 | }
|
866 |
|
867 | this.mode = null;
|
868 | this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
|
869 | break;
|
870 | default:
|
871 |
|
872 | if (this.mode) {
|
873 |
|
874 | switch (this.mode) {
|
875 | case Template.modes.EVAL:
|
876 | case Template.modes.ESCAPED:
|
877 | case Template.modes.RAW:
|
878 | if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
|
879 | line += '\n';
|
880 | }
|
881 | }
|
882 | switch (this.mode) {
|
883 |
|
884 | case Template.modes.EVAL:
|
885 | this.source += ' ; ' + line + '\n';
|
886 | break;
|
887 |
|
888 | case Template.modes.ESCAPED:
|
889 | this.source += ' ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';
|
890 | break;
|
891 |
|
892 | case Template.modes.RAW:
|
893 | this.source += ' ; __append(' + stripSemi(line) + ')' + '\n';
|
894 | break;
|
895 | case Template.modes.COMMENT:
|
896 |
|
897 | break;
|
898 |
|
899 | case Template.modes.LITERAL:
|
900 | this._addOutput(line);
|
901 | break;
|
902 | }
|
903 | }
|
904 |
|
905 | else {
|
906 | this._addOutput(line);
|
907 | }
|
908 | }
|
909 |
|
910 | if (self.opts.compileDebug && newLineCount) {
|
911 | this.currentLine += newLineCount;
|
912 | this.source += ' ; __line = ' + this.currentLine + '\n';
|
913 | }
|
914 | }
|
915 | };
|
916 |
|
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 | exports.escapeXML = utils.escapeXML;
|
930 |
|
931 |
|
932 |
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 | exports.__express = exports.renderFile;
|
941 |
|
942 |
|
943 |
|
944 | if (require.extensions) {
|
945 | require.extensions['.ejs'] = function (module, flnm) {
|
946 | console.log('Deprecated: this API will go away in EJS v2.8');
|
947 | var filename = flnm || module.filename;
|
948 | var options = {
|
949 | filename: filename,
|
950 | client: true
|
951 | };
|
952 | var template = fileLoader(filename).toString();
|
953 | var fn = exports.compile(template, options);
|
954 | module._compile('module.exports = ' + fn.toString() + ';', filename);
|
955 | };
|
956 | }
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 | exports.VERSION = _VERSION_STRING;
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 | exports.name = _NAME;
|
977 |
|
978 |
|
979 | if (typeof window != 'undefined') {
|
980 | window.ejs = exports;
|
981 | }
|
982 |
|
983 | },{"../package.json":6,"./utils":2,"fs":3,"path":4}],2:[function(require,module,exports){
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 |
|
1007 |
|
1008 | 'use strict';
|
1009 |
|
1010 | var regExpChars = /[|\\{}()[\]^$+*?.]/g;
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 |
|
1021 |
|
1022 | exports.escapeRegExpChars = function (string) {
|
1023 |
|
1024 | if (!string) {
|
1025 | return '';
|
1026 | }
|
1027 | return String(string).replace(regExpChars, '\\$&');
|
1028 | };
|
1029 |
|
1030 | var _ENCODE_HTML_RULES = {
|
1031 | '&': '&',
|
1032 | '<': '<',
|
1033 | '>': '>',
|
1034 | '"': '"',
|
1035 | "'": '''
|
1036 | };
|
1037 | var _MATCH_HTML = /[&<>'"]/g;
|
1038 |
|
1039 | function encode_char(c) {
|
1040 | return _ENCODE_HTML_RULES[c] || c;
|
1041 | }
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 |
|
1051 |
|
1052 | var escapeFuncStr =
|
1053 | 'var _ENCODE_HTML_RULES = {\n'
|
1054 | + ' "&": "&"\n'
|
1055 | + ' , "<": "<"\n'
|
1056 | + ' , ">": ">"\n'
|
1057 | + ' , \'"\': """\n'
|
1058 | + ' , "\'": "'"\n'
|
1059 | + ' }\n'
|
1060 | + ' , _MATCH_HTML = /[&<>\'"]/g;\n'
|
1061 | + 'function encode_char(c) {\n'
|
1062 | + ' return _ENCODE_HTML_RULES[c] || c;\n'
|
1063 | + '};\n';
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 | exports.escapeXML = function (markup) {
|
1078 | return markup == undefined
|
1079 | ? ''
|
1080 | : String(markup)
|
1081 | .replace(_MATCH_HTML, encode_char);
|
1082 | };
|
1083 | exports.escapeXML.toString = function () {
|
1084 | return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
|
1085 | };
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 | exports.shallowCopy = function (to, from) {
|
1099 | from = from || {};
|
1100 | for (var p in from) {
|
1101 | to[p] = from[p];
|
1102 | }
|
1103 | return to;
|
1104 | };
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 | exports.shallowCopyFromList = function (to, from, list) {
|
1119 | for (var i = 0; i < list.length; i++) {
|
1120 | var p = list[i];
|
1121 | if (typeof from[p] != 'undefined') {
|
1122 | to[p] = from[p];
|
1123 | }
|
1124 | }
|
1125 | return to;
|
1126 | };
|
1127 |
|
1128 |
|
1129 |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 | exports.cache = {
|
1137 | _data: {},
|
1138 | set: function (key, val) {
|
1139 | this._data[key] = val;
|
1140 | },
|
1141 | get: function (key) {
|
1142 | return this._data[key];
|
1143 | },
|
1144 | remove: function (key) {
|
1145 | delete this._data[key];
|
1146 | },
|
1147 | reset: function () {
|
1148 | this._data = {};
|
1149 | }
|
1150 | };
|
1151 |
|
1152 | },{}],3:[function(require,module,exports){
|
1153 |
|
1154 | },{}],4:[function(require,module,exports){
|
1155 | (function (process){
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 |
|
1182 |
|
1183 |
|
1184 | function normalizeArray(parts, allowAboveRoot) {
|
1185 |
|
1186 | var up = 0;
|
1187 | for (var i = parts.length - 1; i >= 0; i--) {
|
1188 | var last = parts[i];
|
1189 | if (last === '.') {
|
1190 | parts.splice(i, 1);
|
1191 | } else if (last === '..') {
|
1192 | parts.splice(i, 1);
|
1193 | up++;
|
1194 | } else if (up) {
|
1195 | parts.splice(i, 1);
|
1196 | up--;
|
1197 | }
|
1198 | }
|
1199 |
|
1200 |
|
1201 | if (allowAboveRoot) {
|
1202 | for (; up--; up) {
|
1203 | parts.unshift('..');
|
1204 | }
|
1205 | }
|
1206 |
|
1207 | return parts;
|
1208 | }
|
1209 |
|
1210 |
|
1211 |
|
1212 | exports.resolve = function() {
|
1213 | var resolvedPath = '',
|
1214 | resolvedAbsolute = false;
|
1215 |
|
1216 | for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
1217 | var path = (i >= 0) ? arguments[i] : process.cwd();
|
1218 |
|
1219 |
|
1220 | if (typeof path !== 'string') {
|
1221 | throw new TypeError('Arguments to path.resolve must be strings');
|
1222 | } else if (!path) {
|
1223 | continue;
|
1224 | }
|
1225 |
|
1226 | resolvedPath = path + '/' + resolvedPath;
|
1227 | resolvedAbsolute = path.charAt(0) === '/';
|
1228 | }
|
1229 |
|
1230 |
|
1231 |
|
1232 |
|
1233 |
|
1234 | resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
1235 | return !!p;
|
1236 | }), !resolvedAbsolute).join('/');
|
1237 |
|
1238 | return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
1239 | };
|
1240 |
|
1241 |
|
1242 |
|
1243 | exports.normalize = function(path) {
|
1244 | var isAbsolute = exports.isAbsolute(path),
|
1245 | trailingSlash = substr(path, -1) === '/';
|
1246 |
|
1247 |
|
1248 | path = normalizeArray(filter(path.split('/'), function(p) {
|
1249 | return !!p;
|
1250 | }), !isAbsolute).join('/');
|
1251 |
|
1252 | if (!path && !isAbsolute) {
|
1253 | path = '.';
|
1254 | }
|
1255 | if (path && trailingSlash) {
|
1256 | path += '/';
|
1257 | }
|
1258 |
|
1259 | return (isAbsolute ? '/' : '') + path;
|
1260 | };
|
1261 |
|
1262 |
|
1263 | exports.isAbsolute = function(path) {
|
1264 | return path.charAt(0) === '/';
|
1265 | };
|
1266 |
|
1267 |
|
1268 | exports.join = function() {
|
1269 | var paths = Array.prototype.slice.call(arguments, 0);
|
1270 | return exports.normalize(filter(paths, function(p, index) {
|
1271 | if (typeof p !== 'string') {
|
1272 | throw new TypeError('Arguments to path.join must be strings');
|
1273 | }
|
1274 | return p;
|
1275 | }).join('/'));
|
1276 | };
|
1277 |
|
1278 |
|
1279 |
|
1280 |
|
1281 | exports.relative = function(from, to) {
|
1282 | from = exports.resolve(from).substr(1);
|
1283 | to = exports.resolve(to).substr(1);
|
1284 |
|
1285 | function trim(arr) {
|
1286 | var start = 0;
|
1287 | for (; start < arr.length; start++) {
|
1288 | if (arr[start] !== '') break;
|
1289 | }
|
1290 |
|
1291 | var end = arr.length - 1;
|
1292 | for (; end >= 0; end--) {
|
1293 | if (arr[end] !== '') break;
|
1294 | }
|
1295 |
|
1296 | if (start > end) return [];
|
1297 | return arr.slice(start, end - start + 1);
|
1298 | }
|
1299 |
|
1300 | var fromParts = trim(from.split('/'));
|
1301 | var toParts = trim(to.split('/'));
|
1302 |
|
1303 | var length = Math.min(fromParts.length, toParts.length);
|
1304 | var samePartsLength = length;
|
1305 | for (var i = 0; i < length; i++) {
|
1306 | if (fromParts[i] !== toParts[i]) {
|
1307 | samePartsLength = i;
|
1308 | break;
|
1309 | }
|
1310 | }
|
1311 |
|
1312 | var outputParts = [];
|
1313 | for (var i = samePartsLength; i < fromParts.length; i++) {
|
1314 | outputParts.push('..');
|
1315 | }
|
1316 |
|
1317 | outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
1318 |
|
1319 | return outputParts.join('/');
|
1320 | };
|
1321 |
|
1322 | exports.sep = '/';
|
1323 | exports.delimiter = ':';
|
1324 |
|
1325 | exports.dirname = function (path) {
|
1326 | if (typeof path !== 'string') path = path + '';
|
1327 | if (path.length === 0) return '.';
|
1328 | var code = path.charCodeAt(0);
|
1329 | var hasRoot = code === 47 ;
|
1330 | var end = -1;
|
1331 | var matchedSlash = true;
|
1332 | for (var i = path.length - 1; i >= 1; --i) {
|
1333 | code = path.charCodeAt(i);
|
1334 | if (code === 47 ) {
|
1335 | if (!matchedSlash) {
|
1336 | end = i;
|
1337 | break;
|
1338 | }
|
1339 | } else {
|
1340 |
|
1341 | matchedSlash = false;
|
1342 | }
|
1343 | }
|
1344 |
|
1345 | if (end === -1) return hasRoot ? '/' : '.';
|
1346 | if (hasRoot && end === 1) {
|
1347 |
|
1348 |
|
1349 | return '/';
|
1350 | }
|
1351 | return path.slice(0, end);
|
1352 | };
|
1353 |
|
1354 | function basename(path) {
|
1355 | if (typeof path !== 'string') path = path + '';
|
1356 |
|
1357 | var start = 0;
|
1358 | var end = -1;
|
1359 | var matchedSlash = true;
|
1360 | var i;
|
1361 |
|
1362 | for (i = path.length - 1; i >= 0; --i) {
|
1363 | if (path.charCodeAt(i) === 47 ) {
|
1364 |
|
1365 |
|
1366 | if (!matchedSlash) {
|
1367 | start = i + 1;
|
1368 | break;
|
1369 | }
|
1370 | } else if (end === -1) {
|
1371 |
|
1372 |
|
1373 | matchedSlash = false;
|
1374 | end = i + 1;
|
1375 | }
|
1376 | }
|
1377 |
|
1378 | if (end === -1) return '';
|
1379 | return path.slice(start, end);
|
1380 | }
|
1381 |
|
1382 |
|
1383 |
|
1384 | exports.basename = function (path, ext) {
|
1385 | var f = basename(path);
|
1386 | if (ext && f.substr(-1 * ext.length) === ext) {
|
1387 | f = f.substr(0, f.length - ext.length);
|
1388 | }
|
1389 | return f;
|
1390 | };
|
1391 |
|
1392 | exports.extname = function (path) {
|
1393 | if (typeof path !== 'string') path = path + '';
|
1394 | var startDot = -1;
|
1395 | var startPart = 0;
|
1396 | var end = -1;
|
1397 | var matchedSlash = true;
|
1398 |
|
1399 |
|
1400 | var preDotState = 0;
|
1401 | for (var i = path.length - 1; i >= 0; --i) {
|
1402 | var code = path.charCodeAt(i);
|
1403 | if (code === 47 ) {
|
1404 |
|
1405 |
|
1406 | if (!matchedSlash) {
|
1407 | startPart = i + 1;
|
1408 | break;
|
1409 | }
|
1410 | continue;
|
1411 | }
|
1412 | if (end === -1) {
|
1413 |
|
1414 |
|
1415 | matchedSlash = false;
|
1416 | end = i + 1;
|
1417 | }
|
1418 | if (code === 46 ) {
|
1419 |
|
1420 | if (startDot === -1)
|
1421 | startDot = i;
|
1422 | else if (preDotState !== 1)
|
1423 | preDotState = 1;
|
1424 | } else if (startDot !== -1) {
|
1425 |
|
1426 |
|
1427 | preDotState = -1;
|
1428 | }
|
1429 | }
|
1430 |
|
1431 | if (startDot === -1 || end === -1 ||
|
1432 |
|
1433 | preDotState === 0 ||
|
1434 |
|
1435 | preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
1436 | return '';
|
1437 | }
|
1438 | return path.slice(startDot, end);
|
1439 | };
|
1440 |
|
1441 | function filter (xs, f) {
|
1442 | if (xs.filter) return xs.filter(f);
|
1443 | var res = [];
|
1444 | for (var i = 0; i < xs.length; i++) {
|
1445 | if (f(xs[i], i, xs)) res.push(xs[i]);
|
1446 | }
|
1447 | return res;
|
1448 | }
|
1449 |
|
1450 |
|
1451 | var substr = 'ab'.substr(-1) === 'b'
|
1452 | ? function (str, start, len) { return str.substr(start, len) }
|
1453 | : function (str, start, len) {
|
1454 | if (start < 0) start = str.length + start;
|
1455 | return str.substr(start, len);
|
1456 | }
|
1457 | ;
|
1458 |
|
1459 | }).call(this,require('_process'))
|
1460 | },{"_process":5}],5:[function(require,module,exports){
|
1461 |
|
1462 | var process = module.exports = {};
|
1463 |
|
1464 |
|
1465 |
|
1466 |
|
1467 |
|
1468 |
|
1469 | var cachedSetTimeout;
|
1470 | var cachedClearTimeout;
|
1471 |
|
1472 | function defaultSetTimout() {
|
1473 | throw new Error('setTimeout has not been defined');
|
1474 | }
|
1475 | function defaultClearTimeout () {
|
1476 | throw new Error('clearTimeout has not been defined');
|
1477 | }
|
1478 | (function () {
|
1479 | try {
|
1480 | if (typeof setTimeout === 'function') {
|
1481 | cachedSetTimeout = setTimeout;
|
1482 | } else {
|
1483 | cachedSetTimeout = defaultSetTimout;
|
1484 | }
|
1485 | } catch (e) {
|
1486 | cachedSetTimeout = defaultSetTimout;
|
1487 | }
|
1488 | try {
|
1489 | if (typeof clearTimeout === 'function') {
|
1490 | cachedClearTimeout = clearTimeout;
|
1491 | } else {
|
1492 | cachedClearTimeout = defaultClearTimeout;
|
1493 | }
|
1494 | } catch (e) {
|
1495 | cachedClearTimeout = defaultClearTimeout;
|
1496 | }
|
1497 | } ())
|
1498 | function runTimeout(fun) {
|
1499 | if (cachedSetTimeout === setTimeout) {
|
1500 |
|
1501 | return setTimeout(fun, 0);
|
1502 | }
|
1503 |
|
1504 | if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
1505 | cachedSetTimeout = setTimeout;
|
1506 | return setTimeout(fun, 0);
|
1507 | }
|
1508 | try {
|
1509 |
|
1510 | return cachedSetTimeout(fun, 0);
|
1511 | } catch(e){
|
1512 | try {
|
1513 |
|
1514 | return cachedSetTimeout.call(null, fun, 0);
|
1515 | } catch(e){
|
1516 |
|
1517 | return cachedSetTimeout.call(this, fun, 0);
|
1518 | }
|
1519 | }
|
1520 |
|
1521 |
|
1522 | }
|
1523 | function runClearTimeout(marker) {
|
1524 | if (cachedClearTimeout === clearTimeout) {
|
1525 |
|
1526 | return clearTimeout(marker);
|
1527 | }
|
1528 |
|
1529 | if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
1530 | cachedClearTimeout = clearTimeout;
|
1531 | return clearTimeout(marker);
|
1532 | }
|
1533 | try {
|
1534 |
|
1535 | return cachedClearTimeout(marker);
|
1536 | } catch (e){
|
1537 | try {
|
1538 |
|
1539 | return cachedClearTimeout.call(null, marker);
|
1540 | } catch (e){
|
1541 |
|
1542 |
|
1543 | return cachedClearTimeout.call(this, marker);
|
1544 | }
|
1545 | }
|
1546 |
|
1547 |
|
1548 |
|
1549 | }
|
1550 | var queue = [];
|
1551 | var draining = false;
|
1552 | var currentQueue;
|
1553 | var queueIndex = -1;
|
1554 |
|
1555 | function cleanUpNextTick() {
|
1556 | if (!draining || !currentQueue) {
|
1557 | return;
|
1558 | }
|
1559 | draining = false;
|
1560 | if (currentQueue.length) {
|
1561 | queue = currentQueue.concat(queue);
|
1562 | } else {
|
1563 | queueIndex = -1;
|
1564 | }
|
1565 | if (queue.length) {
|
1566 | drainQueue();
|
1567 | }
|
1568 | }
|
1569 |
|
1570 | function drainQueue() {
|
1571 | if (draining) {
|
1572 | return;
|
1573 | }
|
1574 | var timeout = runTimeout(cleanUpNextTick);
|
1575 | draining = true;
|
1576 |
|
1577 | var len = queue.length;
|
1578 | while(len) {
|
1579 | currentQueue = queue;
|
1580 | queue = [];
|
1581 | while (++queueIndex < len) {
|
1582 | if (currentQueue) {
|
1583 | currentQueue[queueIndex].run();
|
1584 | }
|
1585 | }
|
1586 | queueIndex = -1;
|
1587 | len = queue.length;
|
1588 | }
|
1589 | currentQueue = null;
|
1590 | draining = false;
|
1591 | runClearTimeout(timeout);
|
1592 | }
|
1593 |
|
1594 | process.nextTick = function (fun) {
|
1595 | var args = new Array(arguments.length - 1);
|
1596 | if (arguments.length > 1) {
|
1597 | for (var i = 1; i < arguments.length; i++) {
|
1598 | args[i - 1] = arguments[i];
|
1599 | }
|
1600 | }
|
1601 | queue.push(new Item(fun, args));
|
1602 | if (queue.length === 1 && !draining) {
|
1603 | runTimeout(drainQueue);
|
1604 | }
|
1605 | };
|
1606 |
|
1607 |
|
1608 | function Item(fun, array) {
|
1609 | this.fun = fun;
|
1610 | this.array = array;
|
1611 | }
|
1612 | Item.prototype.run = function () {
|
1613 | this.fun.apply(null, this.array);
|
1614 | };
|
1615 | process.title = 'browser';
|
1616 | process.browser = true;
|
1617 | process.env = {};
|
1618 | process.argv = [];
|
1619 | process.version = '';
|
1620 | process.versions = {};
|
1621 |
|
1622 | function noop() {}
|
1623 |
|
1624 | process.on = noop;
|
1625 | process.addListener = noop;
|
1626 | process.once = noop;
|
1627 | process.off = noop;
|
1628 | process.removeListener = noop;
|
1629 | process.removeAllListeners = noop;
|
1630 | process.emit = noop;
|
1631 | process.prependListener = noop;
|
1632 | process.prependOnceListener = noop;
|
1633 |
|
1634 | process.listeners = function (name) { return [] }
|
1635 |
|
1636 | process.binding = function (name) {
|
1637 | throw new Error('process.binding is not supported');
|
1638 | };
|
1639 |
|
1640 | process.cwd = function () { return '/' };
|
1641 | process.chdir = function (dir) {
|
1642 | throw new Error('process.chdir is not supported');
|
1643 | };
|
1644 | process.umask = function() { return 0; };
|
1645 |
|
1646 | },{}],6:[function(require,module,exports){
|
1647 | module.exports={
|
1648 | "name": "ejs",
|
1649 | "description": "Embedded JavaScript templates",
|
1650 | "keywords": [
|
1651 | "template",
|
1652 | "engine",
|
1653 | "ejs"
|
1654 | ],
|
1655 | "version": "2.7.4",
|
1656 | "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
|
1657 | "license": "Apache-2.0",
|
1658 | "main": "./lib/ejs.js",
|
1659 | "repository": {
|
1660 | "type": "git",
|
1661 | "url": "git://github.com/mde/ejs.git"
|
1662 | },
|
1663 | "bugs": "https://github.com/mde/ejs/issues",
|
1664 | "homepage": "https://github.com/mde/ejs",
|
1665 | "dependencies": {},
|
1666 | "devDependencies": {
|
1667 | "browserify": "^13.1.1",
|
1668 | "eslint": "^4.14.0",
|
1669 | "git-directory-deploy": "^1.5.1",
|
1670 | "jake": "^10.3.1",
|
1671 | "jsdoc": "^3.4.0",
|
1672 | "lru-cache": "^4.0.1",
|
1673 | "mocha": "^5.0.5",
|
1674 | "uglify-js": "^3.3.16"
|
1675 | },
|
1676 | "engines": {
|
1677 | "node": ">=0.10.0"
|
1678 | },
|
1679 | "scripts": {
|
1680 | "test": "mocha",
|
1681 | "postinstall": "node ./postinstall.js"
|
1682 | }
|
1683 | }
|
1684 |
|
1685 | },{}]},{},[1])(1)
|
1686 | });
|