source: frontend/node_modules/ejs/ejs.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 49.0 KB
Line 
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 * EJS Embedded JavaScript templates
4 * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18*/
19
20'use strict';
21
22/**
23 * @file Embedded JavaScript templating engine. {@link http://ejs.co}
24 * @author Matthew Eernisse <mde@fleegix.org>
25 * @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
26 * @project EJS
27 * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
28 */
29
30/**
31 * EJS internal functions.
32 *
33 * Technically this "module" lies in the same file as {@link module:ejs}, for
34 * the sake of organization all the private functions re grouped into this
35 * module.
36 *
37 * @module ejs-internal
38 * @private
39 */
40
41/**
42 * Embedded JavaScript templating engine.
43 *
44 * @module ejs
45 * @public
46 */
47
48
49var fs = require('fs');
50var path = require('path');
51var utils = require('./utils');
52
53var scopeOptionWarned = false;
54/** @type {string} */
55var _VERSION_STRING = require('../package.json').version;
56var _DEFAULT_OPEN_DELIMITER = '<';
57var _DEFAULT_CLOSE_DELIMITER = '>';
58var _DEFAULT_DELIMITER = '%';
59var _DEFAULT_LOCALS_NAME = 'locals';
60var _NAME = 'ejs';
61var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';
62var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',
63 'client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];
64// We don't allow 'cache' option to be passed in the data obj for
65// the normal `render` call, but this is where Express 2 & 3 put it
66// so we make an exception for `renderFile`
67var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
68var _BOM = /^\uFEFF/;
69var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
70
71/**
72 * EJS template function cache. This can be a LRU object from lru-cache NPM
73 * module. By default, it is {@link module:utils.cache}, a simple in-process
74 * cache that grows continuously.
75 *
76 * @type {Cache}
77 */
78
79exports.cache = utils.cache;
80
81/**
82 * Custom file loader. Useful for template preprocessing or restricting access
83 * to a certain part of the filesystem.
84 *
85 * @type {fileLoader}
86 */
87
88exports.fileLoader = fs.readFileSync;
89
90/**
91 * Name of the object containing the locals.
92 *
93 * This variable is overridden by {@link Options}`.localsName` if it is not
94 * `undefined`.
95 *
96 * @type {String}
97 * @public
98 */
99
100exports.localsName = _DEFAULT_LOCALS_NAME;
101
102/**
103 * Promise implementation -- defaults to the native implementation if available
104 * This is mostly just for testability
105 *
106 * @type {PromiseConstructorLike}
107 * @public
108 */
109
110exports.promiseImpl = (new Function('return this;'))().Promise;
111
112/**
113 * Get the path to the included file from the parent file path and the
114 * specified path.
115 *
116 * @param {String} name specified path
117 * @param {String} filename parent file path
118 * @param {Boolean} [isDir=false] whether the parent file path is a directory
119 * @return {String}
120 */
121exports.resolveInclude = function(name, filename, isDir) {
122 var dirname = path.dirname;
123 var extname = path.extname;
124 var resolve = path.resolve;
125 var includePath = resolve(isDir ? filename : dirname(filename), name);
126 var ext = extname(name);
127 if (!ext) {
128 includePath += '.ejs';
129 }
130 return includePath;
131};
132
133/**
134 * Try to resolve file path on multiple directories
135 *
136 * @param {String} name specified path
137 * @param {Array<String>} paths list of possible parent directory paths
138 * @return {String}
139 */
140function resolvePaths(name, paths) {
141 var filePath;
142 if (paths.some(function (v) {
143 filePath = exports.resolveInclude(name, v, true);
144 return fs.existsSync(filePath);
145 })) {
146 return filePath;
147 }
148}
149
150/**
151 * Get the path to the included file by Options
152 *
153 * @param {String} path specified path
154 * @param {Options} options compilation options
155 * @return {String}
156 */
157function getIncludePath(path, options) {
158 var includePath;
159 var filePath;
160 var views = options.views;
161 var match = /^[A-Za-z]+:\\|^\//.exec(path);
162
163 // Abs path
164 if (match && match.length) {
165 path = path.replace(/^\/*/, '');
166 if (Array.isArray(options.root)) {
167 includePath = resolvePaths(path, options.root);
168 } else {
169 includePath = exports.resolveInclude(path, options.root || '/', true);
170 }
171 }
172 // Relative paths
173 else {
174 // Look relative to a passed filename first
175 if (options.filename) {
176 filePath = exports.resolveInclude(path, options.filename);
177 if (fs.existsSync(filePath)) {
178 includePath = filePath;
179 }
180 }
181 // Then look in any views directories
182 if (!includePath && Array.isArray(views)) {
183 includePath = resolvePaths(path, views);
184 }
185 if (!includePath && typeof options.includer !== 'function') {
186 throw new Error('Could not find the include file "' +
187 options.escapeFunction(path) + '"');
188 }
189 }
190 return includePath;
191}
192
193/**
194 * Get the template from a string or a file, either compiled on-the-fly or
195 * read from cache (if enabled), and cache the template if needed.
196 *
197 * If `template` is not set, the file specified in `options.filename` will be
198 * read.
199 *
200 * If `options.cache` is true, this function reads the file from
201 * `options.filename` so it must be set prior to calling this function.
202 *
203 * @memberof module:ejs-internal
204 * @param {Options} options compilation options
205 * @param {String} [template] template source
206 * @return {(TemplateFunction|ClientFunction)}
207 * Depending on the value of `options.client`, either type might be returned.
208 * @static
209 */
210
211function handleCache(options, template) {
212 var func;
213 var filename = options.filename;
214 var hasTemplate = arguments.length > 1;
215
216 if (options.cache) {
217 if (!filename) {
218 throw new Error('cache option requires a filename');
219 }
220 func = exports.cache.get(filename);
221 if (func) {
222 return func;
223 }
224 if (!hasTemplate) {
225 template = fileLoader(filename).toString().replace(_BOM, '');
226 }
227 }
228 else if (!hasTemplate) {
229 // istanbul ignore if: should not happen at all
230 if (!filename) {
231 throw new Error('Internal EJS error: no file name or template '
232 + 'provided');
233 }
234 template = fileLoader(filename).toString().replace(_BOM, '');
235 }
236 func = exports.compile(template, options);
237 if (options.cache) {
238 exports.cache.set(filename, func);
239 }
240 return func;
241}
242
243/**
244 * Try calling handleCache with the given options and data and call the
245 * callback with the result. If an error occurs, call the callback with
246 * the error. Used by renderFile().
247 *
248 * @memberof module:ejs-internal
249 * @param {Options} options compilation options
250 * @param {Object} data template data
251 * @param {RenderFileCallback} cb callback
252 * @static
253 */
254
255function tryHandleCache(options, data, cb) {
256 var result;
257 if (!cb) {
258 if (typeof exports.promiseImpl == 'function') {
259 return new exports.promiseImpl(function (resolve, reject) {
260 try {
261 result = handleCache(options)(data);
262 resolve(result);
263 }
264 catch (err) {
265 reject(err);
266 }
267 });
268 }
269 else {
270 throw new Error('Please provide a callback function');
271 }
272 }
273 else {
274 try {
275 result = handleCache(options)(data);
276 }
277 catch (err) {
278 return cb(err);
279 }
280
281 cb(null, result);
282 }
283}
284
285/**
286 * fileLoader is independent
287 *
288 * @param {String} filePath ejs file path.
289 * @return {String} The contents of the specified file.
290 * @static
291 */
292
293function fileLoader(filePath){
294 return exports.fileLoader(filePath);
295}
296
297/**
298 * Get the template function.
299 *
300 * If `options.cache` is `true`, then the template is cached.
301 *
302 * @memberof module:ejs-internal
303 * @param {String} path path for the specified file
304 * @param {Options} options compilation options
305 * @return {(TemplateFunction|ClientFunction)}
306 * Depending on the value of `options.client`, either type might be returned
307 * @static
308 */
309
310function includeFile(path, options) {
311 var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
312 opts.filename = getIncludePath(path, opts);
313 if (typeof options.includer === 'function') {
314 var includerResult = options.includer(path, opts.filename);
315 if (includerResult) {
316 if (includerResult.filename) {
317 opts.filename = includerResult.filename;
318 }
319 if (includerResult.template) {
320 return handleCache(opts, includerResult.template);
321 }
322 }
323 }
324 return handleCache(opts);
325}
326
327/**
328 * Re-throw the given `err` in context to the `str` of ejs, `filename`, and
329 * `lineno`.
330 *
331 * @implements {RethrowCallback}
332 * @memberof module:ejs-internal
333 * @param {Error} err Error object
334 * @param {String} str EJS source
335 * @param {String} flnm file name of the EJS file
336 * @param {Number} lineno line number of the error
337 * @param {EscapeCallback} esc
338 * @static
339 */
340
341function rethrow(err, str, flnm, lineno, esc) {
342 var lines = str.split('\n');
343 var start = Math.max(lineno - 3, 0);
344 var end = Math.min(lines.length, lineno + 3);
345 var filename = esc(flnm);
346 // Error context
347 var context = lines.slice(start, end).map(function (line, i){
348 var curr = i + start + 1;
349 return (curr == lineno ? ' >> ' : ' ')
350 + curr
351 + '| '
352 + line;
353 }).join('\n');
354
355 // Alter exception message
356 err.path = filename;
357 err.message = (filename || 'ejs') + ':'
358 + lineno + '\n'
359 + context + '\n\n'
360 + err.message;
361
362 throw err;
363}
364
365function stripSemi(str){
366 return str.replace(/;(\s*$)/, '$1');
367}
368
369/**
370 * Compile the given `str` of ejs into a template function.
371 *
372 * @param {String} template EJS template
373 *
374 * @param {Options} [opts] compilation options
375 *
376 * @return {(TemplateFunction|ClientFunction)}
377 * Depending on the value of `opts.client`, either type might be returned.
378 * Note that the return type of the function also depends on the value of `opts.async`.
379 * @public
380 */
381
382exports.compile = function compile(template, opts) {
383 var templ;
384
385 // v1 compat
386 // 'scope' is 'context'
387 // FIXME: Remove this in a future version
388 if (opts && opts.scope) {
389 if (!scopeOptionWarned){
390 console.warn('`scope` option is deprecated and will be removed in EJS 3');
391 scopeOptionWarned = true;
392 }
393 if (!opts.context) {
394 opts.context = opts.scope;
395 }
396 delete opts.scope;
397 }
398 templ = new Template(template, opts);
399 return templ.compile();
400};
401
402/**
403 * Render the given `template` of ejs.
404 *
405 * If you would like to include options but not data, you need to explicitly
406 * call this function with `data` being an empty object or `null`.
407 *
408 * @param {String} template EJS template
409 * @param {Object} [data={}] template data
410 * @param {Options} [opts={}] compilation and rendering options
411 * @return {(String|Promise<String>)}
412 * Return value type depends on `opts.async`.
413 * @public
414 */
415
416exports.render = function (template, d, o) {
417 var data = d || utils.createNullProtoObjWherePossible();
418 var opts = o || utils.createNullProtoObjWherePossible();
419
420 // No options object -- if there are optiony names
421 // in the data, copy them to options
422 if (arguments.length == 2) {
423 utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
424 }
425
426 return handleCache(opts, template)(data);
427};
428
429/**
430 * Render an EJS file at the given `path` and callback `cb(err, str)`.
431 *
432 * If you would like to include options but not data, you need to explicitly
433 * call this function with `data` being an empty object or `null`.
434 *
435 * @param {String} path path to the EJS file
436 * @param {Object} [data={}] template data
437 * @param {Options} [opts={}] compilation and rendering options
438 * @param {RenderFileCallback} cb callback
439 * @public
440 */
441
442exports.renderFile = function () {
443 var args = Array.prototype.slice.call(arguments);
444 var filename = args.shift();
445 var cb;
446 var opts = {filename: filename};
447 var data;
448 var viewOpts;
449
450 // Do we have a callback?
451 if (typeof arguments[arguments.length - 1] == 'function') {
452 cb = args.pop();
453 }
454 // Do we have data/opts?
455 if (args.length) {
456 // Should always have data obj
457 data = args.shift();
458 // Normal passed opts (data obj + opts obj)
459 if (args.length) {
460 // Use shallowCopy so we don't pollute passed in opts obj with new vals
461 utils.shallowCopy(opts, args.pop());
462 }
463 // Special casing for Express (settings + opts-in-data)
464 else {
465 // Express 3 and 4
466 if (data.settings) {
467 // Pull a few things from known locations
468 if (data.settings.views) {
469 opts.views = data.settings.views;
470 }
471 if (data.settings['view cache']) {
472 opts.cache = true;
473 }
474 // Undocumented after Express 2, but still usable, esp. for
475 // items that are unsafe to be passed along with data, like `root`
476 viewOpts = data.settings['view options'];
477 if (viewOpts) {
478 utils.shallowCopy(opts, viewOpts);
479 }
480 }
481 // Express 2 and lower, values set in app.locals, or people who just
482 // want to pass options in their data. NOTE: These values will override
483 // anything previously set in settings or settings['view options']
484 utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
485 }
486 opts.filename = filename;
487 }
488 else {
489 data = utils.createNullProtoObjWherePossible();
490 }
491
492 return tryHandleCache(opts, data, cb);
493};
494
495/**
496 * Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
497 * @public
498 */
499
500/**
501 * EJS template class
502 * @public
503 */
504exports.Template = Template;
505
506exports.clearCache = function () {
507 exports.cache.reset();
508};
509
510function Template(text, optsParam) {
511 var opts = utils.hasOwnOnlyObject(optsParam);
512 var options = utils.createNullProtoObjWherePossible();
513 this.templateText = text;
514 /** @type {string | null} */
515 this.mode = null;
516 this.truncate = false;
517 this.currentLine = 1;
518 this.source = '';
519 options.client = opts.client || false;
520 options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
521 options.compileDebug = opts.compileDebug !== false;
522 options.debug = !!opts.debug;
523 options.filename = opts.filename;
524 options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
525 options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
526 options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
527 options.strict = opts.strict || false;
528 options.context = opts.context;
529 options.cache = opts.cache || false;
530 options.rmWhitespace = opts.rmWhitespace;
531 options.root = opts.root;
532 options.includer = opts.includer;
533 options.outputFunctionName = opts.outputFunctionName;
534 options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
535 options.views = opts.views;
536 options.async = opts.async;
537 options.destructuredLocals = opts.destructuredLocals;
538 options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;
539
540 if (options.strict) {
541 options._with = false;
542 }
543 else {
544 options._with = typeof opts._with != 'undefined' ? opts._with : true;
545 }
546
547 this.opts = options;
548
549 this.regex = this.createRegex();
550}
551
552Template.modes = {
553 EVAL: 'eval',
554 ESCAPED: 'escaped',
555 RAW: 'raw',
556 COMMENT: 'comment',
557 LITERAL: 'literal'
558};
559
560Template.prototype = {
561 createRegex: function () {
562 var str = _REGEX_STRING;
563 var delim = utils.escapeRegExpChars(this.opts.delimiter);
564 var open = utils.escapeRegExpChars(this.opts.openDelimiter);
565 var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
566 str = str.replace(/%/g, delim)
567 .replace(/</g, open)
568 .replace(/>/g, close);
569 return new RegExp(str);
570 },
571
572 compile: function () {
573 /** @type {string} */
574 var src;
575 /** @type {ClientFunction} */
576 var fn;
577 var opts = this.opts;
578 var prepended = '';
579 var appended = '';
580 /** @type {EscapeCallback} */
581 var escapeFn = opts.escapeFunction;
582 /** @type {FunctionConstructor} */
583 var ctor;
584 /** @type {string} */
585 var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : 'undefined';
586
587 if (!this.source) {
588 this.generateSource();
589 prepended +=
590 ' var __output = "";\n' +
591 ' function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
592 if (opts.outputFunctionName) {
593 if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
594 throw new Error('outputFunctionName is not a valid JS identifier.');
595 }
596 prepended += ' var ' + opts.outputFunctionName + ' = __append;' + '\n';
597 }
598 if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
599 throw new Error('localsName is not a valid JS identifier.');
600 }
601 if (opts.destructuredLocals && opts.destructuredLocals.length) {
602 var destructuring = ' var __locals = (' + opts.localsName + ' || {}),\n';
603 for (var i = 0; i < opts.destructuredLocals.length; i++) {
604 var name = opts.destructuredLocals[i];
605 if (!_JS_IDENTIFIER.test(name)) {
606 throw new Error('destructuredLocals[' + i + '] is not a valid JS identifier.');
607 }
608 if (i > 0) {
609 destructuring += ',\n ';
610 }
611 destructuring += name + ' = __locals.' + name;
612 }
613 prepended += destructuring + ';\n';
614 }
615 if (opts._with !== false) {
616 prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
617 appended += ' }' + '\n';
618 }
619 appended += ' return __output;' + '\n';
620 this.source = prepended + this.source + appended;
621 }
622
623 if (opts.compileDebug) {
624 src = 'var __line = 1' + '\n'
625 + ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
626 + ' , __filename = ' + sanitizedFilename + ';' + '\n'
627 + 'try {' + '\n'
628 + this.source
629 + '} catch (e) {' + '\n'
630 + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
631 + '}' + '\n';
632 }
633 else {
634 src = this.source;
635 }
636
637 if (opts.client) {
638 src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
639 if (opts.compileDebug) {
640 src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
641 }
642 }
643
644 if (opts.strict) {
645 src = '"use strict";\n' + src;
646 }
647 if (opts.debug) {
648 console.log(src);
649 }
650 if (opts.compileDebug && opts.filename) {
651 src = src + '\n'
652 + '//# sourceURL=' + sanitizedFilename + '\n';
653 }
654
655 try {
656 if (opts.async) {
657 // Have to use generated function for this, since in envs without support,
658 // it breaks in parsing
659 try {
660 ctor = (new Function('return (async function(){}).constructor;'))();
661 }
662 catch(e) {
663 if (e instanceof SyntaxError) {
664 throw new Error('This environment does not support async/await');
665 }
666 else {
667 throw e;
668 }
669 }
670 }
671 else {
672 ctor = Function;
673 }
674 fn = new ctor(opts.localsName + ', escapeFn, include, rethrow', src);
675 }
676 catch(e) {
677 // istanbul ignore else
678 if (e instanceof SyntaxError) {
679 if (opts.filename) {
680 e.message += ' in ' + opts.filename;
681 }
682 e.message += ' while compiling ejs\n\n';
683 e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';
684 e.message += 'https://github.com/RyanZim/EJS-Lint';
685 if (!opts.async) {
686 e.message += '\n';
687 e.message += 'Or, if you meant to create an async function, pass `async: true` as an option.';
688 }
689 }
690 throw e;
691 }
692
693 // Return a callable function which will execute the function
694 // created by the source-code, with the passed data as locals
695 // Adds a local `include` function which allows full recursive include
696 var returnedFn = opts.client ? fn : function anonymous(data) {
697 var include = function (path, includeData) {
698 var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
699 if (includeData) {
700 d = utils.shallowCopy(d, includeData);
701 }
702 return includeFile(path, opts)(d);
703 };
704 return fn.apply(opts.context,
705 [data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
706 };
707 if (opts.filename && typeof Object.defineProperty === 'function') {
708 var filename = opts.filename;
709 var basename = path.basename(filename, path.extname(filename));
710 try {
711 Object.defineProperty(returnedFn, 'name', {
712 value: basename,
713 writable: false,
714 enumerable: false,
715 configurable: true
716 });
717 } catch (e) {/* ignore */}
718 }
719 return returnedFn;
720 },
721
722 generateSource: function () {
723 var opts = this.opts;
724
725 if (opts.rmWhitespace) {
726 // Have to use two separate replace here as `^` and `$` operators don't
727 // work well with `\r` and empty lines don't work well with the `m` flag.
728 this.templateText =
729 this.templateText.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
730 }
731
732 // Slurp spaces and tabs before <%_ and after _%>
733 this.templateText =
734 this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
735
736 var self = this;
737 var matches = this.parseTemplateText();
738 var d = this.opts.delimiter;
739 var o = this.opts.openDelimiter;
740 var c = this.opts.closeDelimiter;
741
742 if (matches && matches.length) {
743 matches.forEach(function (line, index) {
744 var closing;
745 // If this is an opening tag, check for closing tags
746 // FIXME: May end up with some false positives here
747 // Better to store modes as k/v with openDelimiter + delimiter as key
748 // Then this can simply check against the map
749 if ( line.indexOf(o + d) === 0 // If it is a tag
750 && line.indexOf(o + d + d) !== 0) { // and is not escaped
751 closing = matches[index + 2];
752 if (!(closing == d + c || closing == '-' + d + c || closing == '_' + d + c)) {
753 throw new Error('Could not find matching close tag for "' + line + '".');
754 }
755 }
756 self.scanLine(line);
757 });
758 }
759
760 },
761
762 parseTemplateText: function () {
763 var str = this.templateText;
764 var pat = this.regex;
765 var result = pat.exec(str);
766 var arr = [];
767 var firstPos;
768
769 while (result) {
770 firstPos = result.index;
771
772 if (firstPos !== 0) {
773 arr.push(str.substring(0, firstPos));
774 str = str.slice(firstPos);
775 }
776
777 arr.push(result[0]);
778 str = str.slice(result[0].length);
779 result = pat.exec(str);
780 }
781
782 if (str) {
783 arr.push(str);
784 }
785
786 return arr;
787 },
788
789 _addOutput: function (line) {
790 if (this.truncate) {
791 // Only replace single leading linebreak in the line after
792 // -%> tag -- this is the single, trailing linebreak
793 // after the tag that the truncation mode replaces
794 // Handle Win / Unix / old Mac linebreaks -- do the \r\n
795 // combo first in the regex-or
796 line = line.replace(/^(?:\r\n|\r|\n)/, '');
797 this.truncate = false;
798 }
799 if (!line) {
800 return line;
801 }
802
803 // Preserve literal slashes
804 line = line.replace(/\\/g, '\\\\');
805
806 // Convert linebreaks
807 line = line.replace(/\n/g, '\\n');
808 line = line.replace(/\r/g, '\\r');
809
810 // Escape double-quotes
811 // - this will be the delimiter during execution
812 line = line.replace(/"/g, '\\"');
813 this.source += ' ; __append("' + line + '")' + '\n';
814 },
815
816 scanLine: function (line) {
817 var self = this;
818 var d = this.opts.delimiter;
819 var o = this.opts.openDelimiter;
820 var c = this.opts.closeDelimiter;
821 var newLineCount = 0;
822
823 newLineCount = (line.split('\n').length - 1);
824
825 switch (line) {
826 case o + d:
827 case o + d + '_':
828 this.mode = Template.modes.EVAL;
829 break;
830 case o + d + '=':
831 this.mode = Template.modes.ESCAPED;
832 break;
833 case o + d + '-':
834 this.mode = Template.modes.RAW;
835 break;
836 case o + d + '#':
837 this.mode = Template.modes.COMMENT;
838 break;
839 case o + d + d:
840 this.mode = Template.modes.LITERAL;
841 this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + '\n';
842 break;
843 case d + d + c:
844 this.mode = Template.modes.LITERAL;
845 this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + '\n';
846 break;
847 case d + c:
848 case '-' + d + c:
849 case '_' + d + c:
850 if (this.mode == Template.modes.LITERAL) {
851 this._addOutput(line);
852 }
853
854 this.mode = null;
855 this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
856 break;
857 default:
858 // In script mode, depends on type of tag
859 if (this.mode) {
860 // If '//' is found without a line break, add a line break.
861 switch (this.mode) {
862 case Template.modes.EVAL:
863 case Template.modes.ESCAPED:
864 case Template.modes.RAW:
865 if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
866 line += '\n';
867 }
868 }
869 switch (this.mode) {
870 // Just executing code
871 case Template.modes.EVAL:
872 this.source += ' ; ' + line + '\n';
873 break;
874 // Exec, esc, and output
875 case Template.modes.ESCAPED:
876 this.source += ' ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';
877 break;
878 // Exec and output
879 case Template.modes.RAW:
880 this.source += ' ; __append(' + stripSemi(line) + ')' + '\n';
881 break;
882 case Template.modes.COMMENT:
883 // Do nothing
884 break;
885 // Literal <%% mode, append as raw output
886 case Template.modes.LITERAL:
887 this._addOutput(line);
888 break;
889 }
890 }
891 // In string mode, just add the output
892 else {
893 this._addOutput(line);
894 }
895 }
896
897 if (self.opts.compileDebug && newLineCount) {
898 this.currentLine += newLineCount;
899 this.source += ' ; __line = ' + this.currentLine + '\n';
900 }
901 }
902};
903
904/**
905 * Escape characters reserved in XML.
906 *
907 * This is simply an export of {@link module:utils.escapeXML}.
908 *
909 * If `markup` is `undefined` or `null`, the empty string is returned.
910 *
911 * @param {String} markup Input string
912 * @return {String} Escaped string
913 * @public
914 * @func
915 * */
916exports.escapeXML = utils.escapeXML;
917
918/**
919 * Express.js support.
920 *
921 * This is an alias for {@link module:ejs.renderFile}, in order to support
922 * Express.js out-of-the-box.
923 *
924 * @func
925 */
926
927exports.__express = exports.renderFile;
928
929/**
930 * Version of EJS.
931 *
932 * @readonly
933 * @type {String}
934 * @public
935 */
936
937exports.VERSION = _VERSION_STRING;
938
939/**
940 * Name for detection of EJS.
941 *
942 * @readonly
943 * @type {String}
944 * @public
945 */
946
947exports.name = _NAME;
948
949/* istanbul ignore if */
950if (typeof window != 'undefined') {
951 window.ejs = exports;
952}
953
954
955},{"../package.json":6,"./utils":2,"fs":3,"path":4}],2:[function(require,module,exports){
956/*
957 * EJS Embedded JavaScript templates
958 * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
959 *
960 * Licensed under the Apache License, Version 2.0 (the "License");
961 * you may not use this file except in compliance with the License.
962 * You may obtain a copy of the License at
963 *
964 * http://www.apache.org/licenses/LICENSE-2.0
965 *
966 * Unless required by applicable law or agreed to in writing, software
967 * distributed under the License is distributed on an "AS IS" BASIS,
968 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
969 * See the License for the specific language governing permissions and
970 * limitations under the License.
971 *
972*/
973
974/**
975 * Private utility functions
976 * @module utils
977 * @private
978 */
979
980'use strict';
981
982var regExpChars = /[|\\{}()[\]^$+*?.]/g;
983var hasOwnProperty = Object.prototype.hasOwnProperty;
984var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };
985
986/**
987 * Escape characters reserved in regular expressions.
988 *
989 * If `string` is `undefined` or `null`, the empty string is returned.
990 *
991 * @param {String} string Input string
992 * @return {String} Escaped string
993 * @static
994 * @private
995 */
996exports.escapeRegExpChars = function (string) {
997 // istanbul ignore if
998 if (!string) {
999 return '';
1000 }
1001 return String(string).replace(regExpChars, '\\$&');
1002};
1003
1004var _ENCODE_HTML_RULES = {
1005 '&': '&amp;',
1006 '<': '&lt;',
1007 '>': '&gt;',
1008 '"': '&#34;',
1009 "'": '&#39;'
1010};
1011var _MATCH_HTML = /[&<>'"]/g;
1012
1013function encode_char(c) {
1014 return _ENCODE_HTML_RULES[c] || c;
1015}
1016
1017/**
1018 * Stringified version of constants used by {@link module:utils.escapeXML}.
1019 *
1020 * It is used in the process of generating {@link ClientFunction}s.
1021 *
1022 * @readonly
1023 * @type {String}
1024 */
1025
1026var escapeFuncStr =
1027 'var _ENCODE_HTML_RULES = {\n'
1028+ ' "&": "&amp;"\n'
1029+ ' , "<": "&lt;"\n'
1030+ ' , ">": "&gt;"\n'
1031+ ' , \'"\': "&#34;"\n'
1032+ ' , "\'": "&#39;"\n'
1033+ ' }\n'
1034+ ' , _MATCH_HTML = /[&<>\'"]/g;\n'
1035+ 'function encode_char(c) {\n'
1036+ ' return _ENCODE_HTML_RULES[c] || c;\n'
1037+ '};\n';
1038
1039/**
1040 * Escape characters reserved in XML.
1041 *
1042 * If `markup` is `undefined` or `null`, the empty string is returned.
1043 *
1044 * @implements {EscapeCallback}
1045 * @param {String} markup Input string
1046 * @return {String} Escaped string
1047 * @static
1048 * @private
1049 */
1050
1051exports.escapeXML = function (markup) {
1052 return markup == undefined
1053 ? ''
1054 : String(markup)
1055 .replace(_MATCH_HTML, encode_char);
1056};
1057
1058function escapeXMLToString() {
1059 return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
1060}
1061
1062try {
1063 if (typeof Object.defineProperty === 'function') {
1064 // If the Function prototype is frozen, the "toString" property is non-writable. This means that any objects which inherit this property
1065 // cannot have the property changed using an assignment. If using strict mode, attempting that will cause an error. If not using strict
1066 // mode, attempting that will be silently ignored.
1067 // However, we can still explicitly shadow the prototype's "toString" property by defining a new "toString" property on this object.
1068 Object.defineProperty(exports.escapeXML, 'toString', { value: escapeXMLToString });
1069 } else {
1070 // If Object.defineProperty() doesn't exist, attempt to shadow this property using the assignment operator.
1071 exports.escapeXML.toString = escapeXMLToString;
1072 }
1073} catch (err) {
1074 console.warn('Unable to set escapeXML.toString (is the Function prototype frozen?)');
1075}
1076
1077/**
1078 * Naive copy of properties from one object to another.
1079 * Does not recurse into non-scalar properties
1080 * Does not check to see if the property has a value before copying
1081 *
1082 * @param {Object} to Destination object
1083 * @param {Object} from Source object
1084 * @return {Object} Destination object
1085 * @static
1086 * @private
1087 */
1088exports.shallowCopy = function (to, from) {
1089 from = from || {};
1090 if ((to !== null) && (to !== undefined)) {
1091 for (var p in from) {
1092 if (!hasOwn(from, p)) {
1093 continue;
1094 }
1095 if (p === '__proto__' || p === 'constructor') {
1096 continue;
1097 }
1098 to[p] = from[p];
1099 }
1100 }
1101 return to;
1102};
1103
1104/**
1105 * Naive copy of a list of key names, from one object to another.
1106 * Only copies property if it is actually defined
1107 * Does not recurse into non-scalar properties
1108 *
1109 * @param {Object} to Destination object
1110 * @param {Object} from Source object
1111 * @param {Array} list List of properties to copy
1112 * @return {Object} Destination object
1113 * @static
1114 * @private
1115 */
1116exports.shallowCopyFromList = function (to, from, list) {
1117 list = list || [];
1118 from = from || {};
1119 if ((to !== null) && (to !== undefined)) {
1120 for (var i = 0; i < list.length; i++) {
1121 var p = list[i];
1122 if (typeof from[p] != 'undefined') {
1123 if (!hasOwn(from, p)) {
1124 continue;
1125 }
1126 if (p === '__proto__' || p === 'constructor') {
1127 continue;
1128 }
1129 to[p] = from[p];
1130 }
1131 }
1132 }
1133 return to;
1134};
1135
1136/**
1137 * Simple in-process cache implementation. Does not implement limits of any
1138 * sort.
1139 *
1140 * @implements {Cache}
1141 * @static
1142 * @private
1143 */
1144exports.cache = {
1145 _data: {},
1146 set: function (key, val) {
1147 this._data[key] = val;
1148 },
1149 get: function (key) {
1150 return this._data[key];
1151 },
1152 remove: function (key) {
1153 delete this._data[key];
1154 },
1155 reset: function () {
1156 this._data = {};
1157 }
1158};
1159
1160/**
1161 * Transforms hyphen case variable into camel case.
1162 *
1163 * @param {String} string Hyphen case string
1164 * @return {String} Camel case string
1165 * @static
1166 * @private
1167 */
1168exports.hyphenToCamel = function (str) {
1169 return str.replace(/-[a-z]/g, function (match) { return match[1].toUpperCase(); });
1170};
1171
1172/**
1173 * Returns a null-prototype object in runtimes that support it
1174 *
1175 * @return {Object} Object, prototype will be set to null where possible
1176 * @static
1177 * @private
1178 */
1179exports.createNullProtoObjWherePossible = (function () {
1180 if (typeof Object.create == 'function') {
1181 return function () {
1182 return Object.create(null);
1183 };
1184 }
1185 if (!({__proto__: null} instanceof Object)) {
1186 return function () {
1187 return {__proto__: null};
1188 };
1189 }
1190 // Not possible, just pass through
1191 return function () {
1192 return {};
1193 };
1194})();
1195
1196exports.hasOwnOnlyObject = function (obj) {
1197 var o = exports.createNullProtoObjWherePossible();
1198 for (var p in obj) {
1199 if (hasOwn(obj, p)) {
1200 o[p] = obj[p];
1201 }
1202 }
1203 return o;
1204};
1205
1206
1207},{}],3:[function(require,module,exports){
1208
1209},{}],4:[function(require,module,exports){
1210(function (process){
1211// .dirname, .basename, and .extname methods are extracted from Node.js v8.11.1,
1212// backported and transplited with Babel, with backwards-compat fixes
1213
1214// Copyright Joyent, Inc. and other Node contributors.
1215//
1216// Permission is hereby granted, free of charge, to any person obtaining a
1217// copy of this software and associated documentation files (the
1218// "Software"), to deal in the Software without restriction, including
1219// without limitation the rights to use, copy, modify, merge, publish,
1220// distribute, sublicense, and/or sell copies of the Software, and to permit
1221// persons to whom the Software is furnished to do so, subject to the
1222// following conditions:
1223//
1224// The above copyright notice and this permission notice shall be included
1225// in all copies or substantial portions of the Software.
1226//
1227// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
1228// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1229// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
1230// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
1231// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1232// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
1233// USE OR OTHER DEALINGS IN THE SOFTWARE.
1234
1235// resolves . and .. elements in a path array with directory names there
1236// must be no slashes, empty elements, or device names (c:\) in the array
1237// (so also no leading and trailing slashes - it does not distinguish
1238// relative and absolute paths)
1239function normalizeArray(parts, allowAboveRoot) {
1240 // if the path tries to go above the root, `up` ends up > 0
1241 var up = 0;
1242 for (var i = parts.length - 1; i >= 0; i--) {
1243 var last = parts[i];
1244 if (last === '.') {
1245 parts.splice(i, 1);
1246 } else if (last === '..') {
1247 parts.splice(i, 1);
1248 up++;
1249 } else if (up) {
1250 parts.splice(i, 1);
1251 up--;
1252 }
1253 }
1254
1255 // if the path is allowed to go above the root, restore leading ..s
1256 if (allowAboveRoot) {
1257 for (; up--; up) {
1258 parts.unshift('..');
1259 }
1260 }
1261
1262 return parts;
1263}
1264
1265// path.resolve([from ...], to)
1266// posix version
1267exports.resolve = function() {
1268 var resolvedPath = '',
1269 resolvedAbsolute = false;
1270
1271 for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
1272 var path = (i >= 0) ? arguments[i] : process.cwd();
1273
1274 // Skip empty and invalid entries
1275 if (typeof path !== 'string') {
1276 throw new TypeError('Arguments to path.resolve must be strings');
1277 } else if (!path) {
1278 continue;
1279 }
1280
1281 resolvedPath = path + '/' + resolvedPath;
1282 resolvedAbsolute = path.charAt(0) === '/';
1283 }
1284
1285 // At this point the path should be resolved to a full absolute path, but
1286 // handle relative paths to be safe (might happen when process.cwd() fails)
1287
1288 // Normalize the path
1289 resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
1290 return !!p;
1291 }), !resolvedAbsolute).join('/');
1292
1293 return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
1294};
1295
1296// path.normalize(path)
1297// posix version
1298exports.normalize = function(path) {
1299 var isAbsolute = exports.isAbsolute(path),
1300 trailingSlash = substr(path, -1) === '/';
1301
1302 // Normalize the path
1303 path = normalizeArray(filter(path.split('/'), function(p) {
1304 return !!p;
1305 }), !isAbsolute).join('/');
1306
1307 if (!path && !isAbsolute) {
1308 path = '.';
1309 }
1310 if (path && trailingSlash) {
1311 path += '/';
1312 }
1313
1314 return (isAbsolute ? '/' : '') + path;
1315};
1316
1317// posix version
1318exports.isAbsolute = function(path) {
1319 return path.charAt(0) === '/';
1320};
1321
1322// posix version
1323exports.join = function() {
1324 var paths = Array.prototype.slice.call(arguments, 0);
1325 return exports.normalize(filter(paths, function(p, index) {
1326 if (typeof p !== 'string') {
1327 throw new TypeError('Arguments to path.join must be strings');
1328 }
1329 return p;
1330 }).join('/'));
1331};
1332
1333
1334// path.relative(from, to)
1335// posix version
1336exports.relative = function(from, to) {
1337 from = exports.resolve(from).substr(1);
1338 to = exports.resolve(to).substr(1);
1339
1340 function trim(arr) {
1341 var start = 0;
1342 for (; start < arr.length; start++) {
1343 if (arr[start] !== '') break;
1344 }
1345
1346 var end = arr.length - 1;
1347 for (; end >= 0; end--) {
1348 if (arr[end] !== '') break;
1349 }
1350
1351 if (start > end) return [];
1352 return arr.slice(start, end - start + 1);
1353 }
1354
1355 var fromParts = trim(from.split('/'));
1356 var toParts = trim(to.split('/'));
1357
1358 var length = Math.min(fromParts.length, toParts.length);
1359 var samePartsLength = length;
1360 for (var i = 0; i < length; i++) {
1361 if (fromParts[i] !== toParts[i]) {
1362 samePartsLength = i;
1363 break;
1364 }
1365 }
1366
1367 var outputParts = [];
1368 for (var i = samePartsLength; i < fromParts.length; i++) {
1369 outputParts.push('..');
1370 }
1371
1372 outputParts = outputParts.concat(toParts.slice(samePartsLength));
1373
1374 return outputParts.join('/');
1375};
1376
1377exports.sep = '/';
1378exports.delimiter = ':';
1379
1380exports.dirname = function (path) {
1381 if (typeof path !== 'string') path = path + '';
1382 if (path.length === 0) return '.';
1383 var code = path.charCodeAt(0);
1384 var hasRoot = code === 47 /*/*/;
1385 var end = -1;
1386 var matchedSlash = true;
1387 for (var i = path.length - 1; i >= 1; --i) {
1388 code = path.charCodeAt(i);
1389 if (code === 47 /*/*/) {
1390 if (!matchedSlash) {
1391 end = i;
1392 break;
1393 }
1394 } else {
1395 // We saw the first non-path separator
1396 matchedSlash = false;
1397 }
1398 }
1399
1400 if (end === -1) return hasRoot ? '/' : '.';
1401 if (hasRoot && end === 1) {
1402 // return '//';
1403 // Backwards-compat fix:
1404 return '/';
1405 }
1406 return path.slice(0, end);
1407};
1408
1409function basename(path) {
1410 if (typeof path !== 'string') path = path + '';
1411
1412 var start = 0;
1413 var end = -1;
1414 var matchedSlash = true;
1415 var i;
1416
1417 for (i = path.length - 1; i >= 0; --i) {
1418 if (path.charCodeAt(i) === 47 /*/*/) {
1419 // If we reached a path separator that was not part of a set of path
1420 // separators at the end of the string, stop now
1421 if (!matchedSlash) {
1422 start = i + 1;
1423 break;
1424 }
1425 } else if (end === -1) {
1426 // We saw the first non-path separator, mark this as the end of our
1427 // path component
1428 matchedSlash = false;
1429 end = i + 1;
1430 }
1431 }
1432
1433 if (end === -1) return '';
1434 return path.slice(start, end);
1435}
1436
1437// Uses a mixed approach for backwards-compatibility, as ext behavior changed
1438// in new Node.js versions, so only basename() above is backported here
1439exports.basename = function (path, ext) {
1440 var f = basename(path);
1441 if (ext && f.substr(-1 * ext.length) === ext) {
1442 f = f.substr(0, f.length - ext.length);
1443 }
1444 return f;
1445};
1446
1447exports.extname = function (path) {
1448 if (typeof path !== 'string') path = path + '';
1449 var startDot = -1;
1450 var startPart = 0;
1451 var end = -1;
1452 var matchedSlash = true;
1453 // Track the state of characters (if any) we see before our first dot and
1454 // after any path separator we find
1455 var preDotState = 0;
1456 for (var i = path.length - 1; i >= 0; --i) {
1457 var code = path.charCodeAt(i);
1458 if (code === 47 /*/*/) {
1459 // If we reached a path separator that was not part of a set of path
1460 // separators at the end of the string, stop now
1461 if (!matchedSlash) {
1462 startPart = i + 1;
1463 break;
1464 }
1465 continue;
1466 }
1467 if (end === -1) {
1468 // We saw the first non-path separator, mark this as the end of our
1469 // extension
1470 matchedSlash = false;
1471 end = i + 1;
1472 }
1473 if (code === 46 /*.*/) {
1474 // If this is our first dot, mark it as the start of our extension
1475 if (startDot === -1)
1476 startDot = i;
1477 else if (preDotState !== 1)
1478 preDotState = 1;
1479 } else if (startDot !== -1) {
1480 // We saw a non-dot and non-path separator before our dot, so we should
1481 // have a good chance at having a non-empty extension
1482 preDotState = -1;
1483 }
1484 }
1485
1486 if (startDot === -1 || end === -1 ||
1487 // We saw a non-dot character immediately before the dot
1488 preDotState === 0 ||
1489 // The (right-most) trimmed path component is exactly '..'
1490 preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
1491 return '';
1492 }
1493 return path.slice(startDot, end);
1494};
1495
1496function filter (xs, f) {
1497 if (xs.filter) return xs.filter(f);
1498 var res = [];
1499 for (var i = 0; i < xs.length; i++) {
1500 if (f(xs[i], i, xs)) res.push(xs[i]);
1501 }
1502 return res;
1503}
1504
1505// String.prototype.substr - negative index don't work in IE8
1506var substr = 'ab'.substr(-1) === 'b'
1507 ? function (str, start, len) { return str.substr(start, len) }
1508 : function (str, start, len) {
1509 if (start < 0) start = str.length + start;
1510 return str.substr(start, len);
1511 }
1512;
1513
1514}).call(this,require('_process'))
1515},{"_process":5}],5:[function(require,module,exports){
1516// shim for using process in browser
1517var process = module.exports = {};
1518
1519// cached from whatever global is present so that test runners that stub it
1520// don't break things. But we need to wrap it in a try catch in case it is
1521// wrapped in strict mode code which doesn't define any globals. It's inside a
1522// function because try/catches deoptimize in certain engines.
1523
1524var cachedSetTimeout;
1525var cachedClearTimeout;
1526
1527function defaultSetTimout() {
1528 throw new Error('setTimeout has not been defined');
1529}
1530function defaultClearTimeout () {
1531 throw new Error('clearTimeout has not been defined');
1532}
1533(function () {
1534 try {
1535 if (typeof setTimeout === 'function') {
1536 cachedSetTimeout = setTimeout;
1537 } else {
1538 cachedSetTimeout = defaultSetTimout;
1539 }
1540 } catch (e) {
1541 cachedSetTimeout = defaultSetTimout;
1542 }
1543 try {
1544 if (typeof clearTimeout === 'function') {
1545 cachedClearTimeout = clearTimeout;
1546 } else {
1547 cachedClearTimeout = defaultClearTimeout;
1548 }
1549 } catch (e) {
1550 cachedClearTimeout = defaultClearTimeout;
1551 }
1552} ())
1553function runTimeout(fun) {
1554 if (cachedSetTimeout === setTimeout) {
1555 //normal enviroments in sane situations
1556 return setTimeout(fun, 0);
1557 }
1558 // if setTimeout wasn't available but was latter defined
1559 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1560 cachedSetTimeout = setTimeout;
1561 return setTimeout(fun, 0);
1562 }
1563 try {
1564 // when when somebody has screwed with setTimeout but no I.E. maddness
1565 return cachedSetTimeout(fun, 0);
1566 } catch(e){
1567 try {
1568 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1569 return cachedSetTimeout.call(null, fun, 0);
1570 } catch(e){
1571 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1572 return cachedSetTimeout.call(this, fun, 0);
1573 }
1574 }
1575
1576
1577}
1578function runClearTimeout(marker) {
1579 if (cachedClearTimeout === clearTimeout) {
1580 //normal enviroments in sane situations
1581 return clearTimeout(marker);
1582 }
1583 // if clearTimeout wasn't available but was latter defined
1584 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1585 cachedClearTimeout = clearTimeout;
1586 return clearTimeout(marker);
1587 }
1588 try {
1589 // when when somebody has screwed with setTimeout but no I.E. maddness
1590 return cachedClearTimeout(marker);
1591 } catch (e){
1592 try {
1593 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1594 return cachedClearTimeout.call(null, marker);
1595 } catch (e){
1596 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1597 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1598 return cachedClearTimeout.call(this, marker);
1599 }
1600 }
1601
1602
1603
1604}
1605var queue = [];
1606var draining = false;
1607var currentQueue;
1608var queueIndex = -1;
1609
1610function cleanUpNextTick() {
1611 if (!draining || !currentQueue) {
1612 return;
1613 }
1614 draining = false;
1615 if (currentQueue.length) {
1616 queue = currentQueue.concat(queue);
1617 } else {
1618 queueIndex = -1;
1619 }
1620 if (queue.length) {
1621 drainQueue();
1622 }
1623}
1624
1625function drainQueue() {
1626 if (draining) {
1627 return;
1628 }
1629 var timeout = runTimeout(cleanUpNextTick);
1630 draining = true;
1631
1632 var len = queue.length;
1633 while(len) {
1634 currentQueue = queue;
1635 queue = [];
1636 while (++queueIndex < len) {
1637 if (currentQueue) {
1638 currentQueue[queueIndex].run();
1639 }
1640 }
1641 queueIndex = -1;
1642 len = queue.length;
1643 }
1644 currentQueue = null;
1645 draining = false;
1646 runClearTimeout(timeout);
1647}
1648
1649process.nextTick = function (fun) {
1650 var args = new Array(arguments.length - 1);
1651 if (arguments.length > 1) {
1652 for (var i = 1; i < arguments.length; i++) {
1653 args[i - 1] = arguments[i];
1654 }
1655 }
1656 queue.push(new Item(fun, args));
1657 if (queue.length === 1 && !draining) {
1658 runTimeout(drainQueue);
1659 }
1660};
1661
1662// v8 likes predictible objects
1663function Item(fun, array) {
1664 this.fun = fun;
1665 this.array = array;
1666}
1667Item.prototype.run = function () {
1668 this.fun.apply(null, this.array);
1669};
1670process.title = 'browser';
1671process.browser = true;
1672process.env = {};
1673process.argv = [];
1674process.version = ''; // empty string to avoid regexp issues
1675process.versions = {};
1676
1677function noop() {}
1678
1679process.on = noop;
1680process.addListener = noop;
1681process.once = noop;
1682process.off = noop;
1683process.removeListener = noop;
1684process.removeAllListeners = noop;
1685process.emit = noop;
1686process.prependListener = noop;
1687process.prependOnceListener = noop;
1688
1689process.listeners = function (name) { return [] }
1690
1691process.binding = function (name) {
1692 throw new Error('process.binding is not supported');
1693};
1694
1695process.cwd = function () { return '/' };
1696process.chdir = function (dir) {
1697 throw new Error('process.chdir is not supported');
1698};
1699process.umask = function() { return 0; };
1700
1701},{}],6:[function(require,module,exports){
1702module.exports={
1703 "name": "ejs",
1704 "description": "Embedded JavaScript templates",
1705 "keywords": [
1706 "template",
1707 "engine",
1708 "ejs"
1709 ],
1710 "version": "3.1.9",
1711 "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
1712 "license": "Apache-2.0",
1713 "bin": {
1714 "ejs": "./bin/cli.js"
1715 },
1716 "main": "./lib/ejs.js",
1717 "jsdelivr": "ejs.min.js",
1718 "unpkg": "ejs.min.js",
1719 "repository": {
1720 "type": "git",
1721 "url": "git://github.com/mde/ejs.git"
1722 },
1723 "bugs": "https://github.com/mde/ejs/issues",
1724 "homepage": "https://github.com/mde/ejs",
1725 "dependencies": {
1726 "jake": "^10.8.5"
1727 },
1728 "devDependencies": {
1729 "browserify": "^16.5.1",
1730 "eslint": "^6.8.0",
1731 "git-directory-deploy": "^1.5.1",
1732 "jsdoc": "^4.0.2",
1733 "lru-cache": "^4.0.1",
1734 "mocha": "^10.2.0",
1735 "uglify-js": "^3.3.16"
1736 },
1737 "engines": {
1738 "node": ">=0.10.0"
1739 },
1740 "scripts": {
1741 "test": "npx jake test"
1742 }
1743}
1744
1745},{}]},{},[1])(1)
1746});
Note: See TracBrowser for help on using the repository browser.