ejs.js 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494
  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 e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({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. 'use strict';
  20. /**
  21. * @file Embedded JavaScript templating engine. {@link http://ejs.co}
  22. * @author Matthew Eernisse <mde@fleegix.org>
  23. * @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
  24. * @project EJS
  25. * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
  26. */
  27. /**
  28. * EJS internal functions.
  29. *
  30. * Technically this "module" lies in the same file as {@link module:ejs}, for
  31. * the sake of organization all the private functions re grouped into this
  32. * module.
  33. *
  34. * @module ejs-internal
  35. * @private
  36. */
  37. /**
  38. * Embedded JavaScript templating engine.
  39. *
  40. * @module ejs
  41. * @public
  42. */
  43. var fs = require('fs');
  44. var path = require('path');
  45. var utils = require('./utils');
  46. var scopeOptionWarned = false;
  47. var _VERSION_STRING = require('../package.json').version;
  48. var _DEFAULT_DELIMITER = '%';
  49. var _DEFAULT_LOCALS_NAME = 'locals';
  50. var _NAME = 'ejs';
  51. var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';
  52. var _OPTS = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',
  53. 'client', '_with', 'rmWhitespace', 'strict', 'filename'];
  54. // We don't allow 'cache' option to be passed in the data obj
  55. // for the normal `render` call, but this is where Express puts it
  56. // so we make an exception for `renderFile`
  57. var _OPTS_EXPRESS = _OPTS.concat('cache');
  58. var _BOM = /^\uFEFF/;
  59. /**
  60. * EJS template function cache. This can be a LRU object from lru-cache NPM
  61. * module. By default, it is {@link module:utils.cache}, a simple in-process
  62. * cache that grows continuously.
  63. *
  64. * @type {Cache}
  65. */
  66. exports.cache = utils.cache;
  67. /**
  68. * Custom file loader. Useful for template preprocessing or restricting access
  69. * to a certain part of the filesystem.
  70. *
  71. * @type {fileLoader}
  72. */
  73. exports.fileLoader = fs.readFileSync;
  74. /**
  75. * Name of the object containing the locals.
  76. *
  77. * This variable is overridden by {@link Options}`.localsName` if it is not
  78. * `undefined`.
  79. *
  80. * @type {String}
  81. * @public
  82. */
  83. exports.localsName = _DEFAULT_LOCALS_NAME;
  84. /**
  85. * Get the path to the included file from the parent file path and the
  86. * specified path.
  87. *
  88. * @param {String} name specified path
  89. * @param {String} filename parent file path
  90. * @param {Boolean} isDir parent file path whether is directory
  91. * @return {String}
  92. */
  93. exports.resolveInclude = function(name, filename, isDir) {
  94. var dirname = path.dirname;
  95. var extname = path.extname;
  96. var resolve = path.resolve;
  97. var includePath = resolve(isDir ? filename : dirname(filename), name);
  98. var ext = extname(name);
  99. if (!ext) {
  100. includePath += '.ejs';
  101. }
  102. return includePath;
  103. };
  104. /**
  105. * Get the path to the included file by Options
  106. *
  107. * @param {String} path specified path
  108. * @param {Options} options compilation options
  109. * @return {String}
  110. */
  111. function getIncludePath(path, options) {
  112. var includePath;
  113. var filePath;
  114. var views = options.views;
  115. // Abs path
  116. if (path.charAt(0) == '/') {
  117. includePath = exports.resolveInclude(path.replace(/^\/*/,''), options.root || '/', true);
  118. }
  119. // Relative paths
  120. else {
  121. // Look relative to a passed filename first
  122. if (options.filename) {
  123. filePath = exports.resolveInclude(path, options.filename);
  124. if (fs.existsSync(filePath)) {
  125. includePath = filePath;
  126. }
  127. }
  128. // Then look in any views directories
  129. if (!includePath) {
  130. if (Array.isArray(views) && views.some(function (v) {
  131. filePath = exports.resolveInclude(path, v, true);
  132. return fs.existsSync(filePath);
  133. })) {
  134. includePath = filePath;
  135. }
  136. }
  137. if (!includePath) {
  138. throw new Error('Could not find include include file.');
  139. }
  140. }
  141. return includePath;
  142. }
  143. /**
  144. * Get the template from a string or a file, either compiled on-the-fly or
  145. * read from cache (if enabled), and cache the template if needed.
  146. *
  147. * If `template` is not set, the file specified in `options.filename` will be
  148. * read.
  149. *
  150. * If `options.cache` is true, this function reads the file from
  151. * `options.filename` so it must be set prior to calling this function.
  152. *
  153. * @memberof module:ejs-internal
  154. * @param {Options} options compilation options
  155. * @param {String} [template] template source
  156. * @return {(TemplateFunction|ClientFunction)}
  157. * Depending on the value of `options.client`, either type might be returned.
  158. * @static
  159. */
  160. function handleCache(options, template) {
  161. var func;
  162. var filename = options.filename;
  163. var hasTemplate = arguments.length > 1;
  164. if (options.cache) {
  165. if (!filename) {
  166. throw new Error('cache option requires a filename');
  167. }
  168. func = exports.cache.get(filename);
  169. if (func) {
  170. return func;
  171. }
  172. if (!hasTemplate) {
  173. template = fileLoader(filename).toString().replace(_BOM, '');
  174. }
  175. }
  176. else if (!hasTemplate) {
  177. // istanbul ignore if: should not happen at all
  178. if (!filename) {
  179. throw new Error('Internal EJS error: no file name or template '
  180. + 'provided');
  181. }
  182. template = fileLoader(filename).toString().replace(_BOM, '');
  183. }
  184. func = exports.compile(template, options);
  185. if (options.cache) {
  186. exports.cache.set(filename, func);
  187. }
  188. return func;
  189. }
  190. /**
  191. * Try calling handleCache with the given options and data and call the
  192. * callback with the result. If an error occurs, call the callback with
  193. * the error. Used by renderFile().
  194. *
  195. * @memberof module:ejs-internal
  196. * @param {Options} options compilation options
  197. * @param {Object} data template data
  198. * @param {RenderFileCallback} cb callback
  199. * @static
  200. */
  201. function tryHandleCache(options, data, cb) {
  202. var result;
  203. try {
  204. result = handleCache(options)(data);
  205. }
  206. catch (err) {
  207. return cb(err);
  208. }
  209. return cb(null, result);
  210. }
  211. /**
  212. * fileLoader is independent
  213. *
  214. * @param {String} filePath ejs file path.
  215. * @return {String} The contents of the specified file.
  216. * @static
  217. */
  218. function fileLoader(filePath){
  219. return exports.fileLoader(filePath);
  220. }
  221. /**
  222. * Get the template function.
  223. *
  224. * If `options.cache` is `true`, then the template is cached.
  225. *
  226. * @memberof module:ejs-internal
  227. * @param {String} path path for the specified file
  228. * @param {Options} options compilation options
  229. * @return {(TemplateFunction|ClientFunction)}
  230. * Depending on the value of `options.client`, either type might be returned
  231. * @static
  232. */
  233. function includeFile(path, options) {
  234. var opts = utils.shallowCopy({}, options);
  235. opts.filename = getIncludePath(path, opts);
  236. return handleCache(opts);
  237. }
  238. /**
  239. * Get the JavaScript source of an included file.
  240. *
  241. * @memberof module:ejs-internal
  242. * @param {String} path path for the specified file
  243. * @param {Options} options compilation options
  244. * @return {Object}
  245. * @static
  246. */
  247. function includeSource(path, options) {
  248. var opts = utils.shallowCopy({}, options);
  249. var includePath;
  250. var template;
  251. includePath = getIncludePath(path, opts);
  252. template = fileLoader(includePath).toString().replace(_BOM, '');
  253. opts.filename = includePath;
  254. var templ = new Template(template, opts);
  255. templ.generateSource();
  256. return {
  257. source: templ.source,
  258. filename: includePath,
  259. template: template
  260. };
  261. }
  262. /**
  263. * Re-throw the given `err` in context to the `str` of ejs, `filename`, and
  264. * `lineno`.
  265. *
  266. * @implements RethrowCallback
  267. * @memberof module:ejs-internal
  268. * @param {Error} err Error object
  269. * @param {String} str EJS source
  270. * @param {String} filename file name of the EJS file
  271. * @param {String} lineno line number of the error
  272. * @static
  273. */
  274. function rethrow(err, str, flnm, lineno, esc){
  275. var lines = str.split('\n');
  276. var start = Math.max(lineno - 3, 0);
  277. var end = Math.min(lines.length, lineno + 3);
  278. var filename = esc(flnm); // eslint-disable-line
  279. // Error context
  280. var context = lines.slice(start, end).map(function (line, i){
  281. var curr = i + start + 1;
  282. return (curr == lineno ? ' >> ' : ' ')
  283. + curr
  284. + '| '
  285. + line;
  286. }).join('\n');
  287. // Alter exception message
  288. err.path = filename;
  289. err.message = (filename || 'ejs') + ':'
  290. + lineno + '\n'
  291. + context + '\n\n'
  292. + err.message;
  293. throw err;
  294. }
  295. function stripSemi(str){
  296. return str.replace(/;(\s*$)/, '$1');
  297. }
  298. /**
  299. * Compile the given `str` of ejs into a template function.
  300. *
  301. * @param {String} template EJS template
  302. *
  303. * @param {Options} opts compilation options
  304. *
  305. * @return {(TemplateFunction|ClientFunction)}
  306. * Depending on the value of `opts.client`, either type might be returned.
  307. * @public
  308. */
  309. exports.compile = function compile(template, opts) {
  310. var templ;
  311. // v1 compat
  312. // 'scope' is 'context'
  313. // FIXME: Remove this in a future version
  314. if (opts && opts.scope) {
  315. if (!scopeOptionWarned){
  316. console.warn('`scope` option is deprecated and will be removed in EJS 3');
  317. scopeOptionWarned = true;
  318. }
  319. if (!opts.context) {
  320. opts.context = opts.scope;
  321. }
  322. delete opts.scope;
  323. }
  324. templ = new Template(template, opts);
  325. return templ.compile();
  326. };
  327. /**
  328. * Render the given `template` of ejs.
  329. *
  330. * If you would like to include options but not data, you need to explicitly
  331. * call this function with `data` being an empty object or `null`.
  332. *
  333. * @param {String} template EJS template
  334. * @param {Object} [data={}] template data
  335. * @param {Options} [opts={}] compilation and rendering options
  336. * @return {String}
  337. * @public
  338. */
  339. exports.render = function (template, d, o) {
  340. var data = d || {};
  341. var opts = o || {};
  342. // No options object -- if there are optiony names
  343. // in the data, copy them to options
  344. if (arguments.length == 2) {
  345. utils.shallowCopyFromList(opts, data, _OPTS);
  346. }
  347. return handleCache(opts, template)(data);
  348. };
  349. /**
  350. * Render an EJS file at the given `path` and callback `cb(err, str)`.
  351. *
  352. * If you would like to include options but not data, you need to explicitly
  353. * call this function with `data` being an empty object or `null`.
  354. *
  355. * @param {String} path path to the EJS file
  356. * @param {Object} [data={}] template data
  357. * @param {Options} [opts={}] compilation and rendering options
  358. * @param {RenderFileCallback} cb callback
  359. * @public
  360. */
  361. exports.renderFile = function () {
  362. var filename = arguments[0];
  363. var cb = arguments[arguments.length - 1];
  364. var opts = {filename: filename};
  365. var data;
  366. if (arguments.length > 2) {
  367. data = arguments[1];
  368. // No options object -- if there are optiony names
  369. // in the data, copy them to options
  370. if (arguments.length === 3) {
  371. // Express 4
  372. if (data.settings) {
  373. if (data.settings['view options']) {
  374. utils.shallowCopyFromList(opts, data.settings['view options'], _OPTS_EXPRESS);
  375. }
  376. if (data.settings.views) {
  377. opts.views = data.settings.views;
  378. }
  379. }
  380. // Express 3 and lower
  381. else {
  382. utils.shallowCopyFromList(opts, data, _OPTS_EXPRESS);
  383. }
  384. }
  385. else {
  386. // Use shallowCopy so we don't pollute passed in opts obj with new vals
  387. utils.shallowCopy(opts, arguments[2]);
  388. }
  389. opts.filename = filename;
  390. }
  391. else {
  392. data = {};
  393. }
  394. return tryHandleCache(opts, data, cb);
  395. };
  396. /**
  397. * Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
  398. * @public
  399. */
  400. exports.clearCache = function () {
  401. exports.cache.reset();
  402. };
  403. function Template(text, opts) {
  404. opts = opts || {};
  405. var options = {};
  406. this.templateText = text;
  407. this.mode = null;
  408. this.truncate = false;
  409. this.currentLine = 1;
  410. this.source = '';
  411. this.dependencies = [];
  412. options.client = opts.client || false;
  413. options.escapeFunction = opts.escape || utils.escapeXML;
  414. options.compileDebug = opts.compileDebug !== false;
  415. options.debug = !!opts.debug;
  416. options.filename = opts.filename;
  417. options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
  418. options.strict = opts.strict || false;
  419. options.context = opts.context;
  420. options.cache = opts.cache || false;
  421. options.rmWhitespace = opts.rmWhitespace;
  422. options.root = opts.root;
  423. options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
  424. options.views = opts.views;
  425. if (options.strict) {
  426. options._with = false;
  427. }
  428. else {
  429. options._with = typeof opts._with != 'undefined' ? opts._with : true;
  430. }
  431. this.opts = options;
  432. this.regex = this.createRegex();
  433. }
  434. Template.modes = {
  435. EVAL: 'eval',
  436. ESCAPED: 'escaped',
  437. RAW: 'raw',
  438. COMMENT: 'comment',
  439. LITERAL: 'literal'
  440. };
  441. Template.prototype = {
  442. createRegex: function () {
  443. var str = _REGEX_STRING;
  444. var delim = utils.escapeRegExpChars(this.opts.delimiter);
  445. str = str.replace(/%/g, delim);
  446. return new RegExp(str);
  447. },
  448. compile: function () {
  449. var src;
  450. var fn;
  451. var opts = this.opts;
  452. var prepended = '';
  453. var appended = '';
  454. var escapeFn = opts.escapeFunction;
  455. if (!this.source) {
  456. this.generateSource();
  457. prepended += ' var __output = [], __append = __output.push.bind(__output);' + '\n';
  458. if (opts._with !== false) {
  459. prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
  460. appended += ' }' + '\n';
  461. }
  462. appended += ' return __output.join("");' + '\n';
  463. this.source = prepended + this.source + appended;
  464. }
  465. if (opts.compileDebug) {
  466. src = 'var __line = 1' + '\n'
  467. + ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
  468. + ' , __filename = ' + (opts.filename ?
  469. JSON.stringify(opts.filename) : 'undefined') + ';' + '\n'
  470. + 'try {' + '\n'
  471. + this.source
  472. + '} catch (e) {' + '\n'
  473. + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
  474. + '}' + '\n';
  475. }
  476. else {
  477. src = this.source;
  478. }
  479. if (opts.client) {
  480. src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
  481. if (opts.compileDebug) {
  482. src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
  483. }
  484. }
  485. if (opts.strict) {
  486. src = '"use strict";\n' + src;
  487. }
  488. if (opts.debug) {
  489. console.log(src);
  490. }
  491. try {
  492. fn = new Function(opts.localsName + ', escapeFn, include, rethrow', src);
  493. }
  494. catch(e) {
  495. // istanbul ignore else
  496. if (e instanceof SyntaxError) {
  497. if (opts.filename) {
  498. e.message += ' in ' + opts.filename;
  499. }
  500. e.message += ' while compiling ejs\n\n';
  501. e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';
  502. e.message += 'https://github.com/RyanZim/EJS-Lint';
  503. }
  504. throw e;
  505. }
  506. if (opts.client) {
  507. fn.dependencies = this.dependencies;
  508. return fn;
  509. }
  510. // Return a callable function which will execute the function
  511. // created by the source-code, with the passed data as locals
  512. // Adds a local `include` function which allows full recursive include
  513. var returnedFn = function (data) {
  514. var include = function (path, includeData) {
  515. var d = utils.shallowCopy({}, data);
  516. if (includeData) {
  517. d = utils.shallowCopy(d, includeData);
  518. }
  519. return includeFile(path, opts)(d);
  520. };
  521. return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
  522. };
  523. returnedFn.dependencies = this.dependencies;
  524. return returnedFn;
  525. },
  526. generateSource: function () {
  527. var opts = this.opts;
  528. if (opts.rmWhitespace) {
  529. // Have to use two separate replace here as `^` and `$` operators don't
  530. // work well with `\r`.
  531. this.templateText =
  532. this.templateText.replace(/\r/g, '').replace(/^\s+|\s+$/gm, '');
  533. }
  534. // Slurp spaces and tabs before <%_ and after _%>
  535. this.templateText =
  536. this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
  537. var self = this;
  538. var matches = this.parseTemplateText();
  539. var d = this.opts.delimiter;
  540. if (matches && matches.length) {
  541. matches.forEach(function (line, index) {
  542. var opening;
  543. var closing;
  544. var include;
  545. var includeOpts;
  546. var includeObj;
  547. var includeSrc;
  548. // If this is an opening tag, check for closing tags
  549. // FIXME: May end up with some false positives here
  550. // Better to store modes as k/v with '<' + delimiter as key
  551. // Then this can simply check against the map
  552. if ( line.indexOf('<' + d) === 0 // If it is a tag
  553. && line.indexOf('<' + d + d) !== 0) { // and is not escaped
  554. closing = matches[index + 2];
  555. if (!(closing == d + '>' || closing == '-' + d + '>' || closing == '_' + d + '>')) {
  556. throw new Error('Could not find matching close tag for "' + line + '".');
  557. }
  558. }
  559. // HACK: backward-compat `include` preprocessor directives
  560. if ((include = line.match(/^\s*include\s+(\S+)/))) {
  561. opening = matches[index - 1];
  562. // Must be in EVAL or RAW mode
  563. if (opening && (opening == '<' + d || opening == '<' + d + '-' || opening == '<' + d + '_')) {
  564. includeOpts = utils.shallowCopy({}, self.opts);
  565. includeObj = includeSource(include[1], includeOpts);
  566. if (self.opts.compileDebug) {
  567. includeSrc =
  568. ' ; (function(){' + '\n'
  569. + ' var __line = 1' + '\n'
  570. + ' , __lines = ' + JSON.stringify(includeObj.template) + '\n'
  571. + ' , __filename = ' + JSON.stringify(includeObj.filename) + ';' + '\n'
  572. + ' try {' + '\n'
  573. + includeObj.source
  574. + ' } catch (e) {' + '\n'
  575. + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
  576. + ' }' + '\n'
  577. + ' ; }).call(this)' + '\n';
  578. }else{
  579. includeSrc = ' ; (function(){' + '\n' + includeObj.source +
  580. ' ; }).call(this)' + '\n';
  581. }
  582. self.source += includeSrc;
  583. self.dependencies.push(exports.resolveInclude(include[1],
  584. includeOpts.filename));
  585. return;
  586. }
  587. }
  588. self.scanLine(line);
  589. });
  590. }
  591. },
  592. parseTemplateText: function () {
  593. var str = this.templateText;
  594. var pat = this.regex;
  595. var result = pat.exec(str);
  596. var arr = [];
  597. var firstPos;
  598. while (result) {
  599. firstPos = result.index;
  600. if (firstPos !== 0) {
  601. arr.push(str.substring(0, firstPos));
  602. str = str.slice(firstPos);
  603. }
  604. arr.push(result[0]);
  605. str = str.slice(result[0].length);
  606. result = pat.exec(str);
  607. }
  608. if (str) {
  609. arr.push(str);
  610. }
  611. return arr;
  612. },
  613. _addOutput: function (line) {
  614. if (this.truncate) {
  615. // Only replace single leading linebreak in the line after
  616. // -%> tag -- this is the single, trailing linebreak
  617. // after the tag that the truncation mode replaces
  618. // Handle Win / Unix / old Mac linebreaks -- do the \r\n
  619. // combo first in the regex-or
  620. line = line.replace(/^(?:\r\n|\r|\n)/, '');
  621. this.truncate = false;
  622. }
  623. else if (this.opts.rmWhitespace) {
  624. // rmWhitespace has already removed trailing spaces, just need
  625. // to remove linebreaks
  626. line = line.replace(/^\n/, '');
  627. }
  628. if (!line) {
  629. return line;
  630. }
  631. // Preserve literal slashes
  632. line = line.replace(/\\/g, '\\\\');
  633. // Convert linebreaks
  634. line = line.replace(/\n/g, '\\n');
  635. line = line.replace(/\r/g, '\\r');
  636. // Escape double-quotes
  637. // - this will be the delimiter during execution
  638. line = line.replace(/"/g, '\\"');
  639. this.source += ' ; __append("' + line + '")' + '\n';
  640. },
  641. scanLine: function (line) {
  642. var self = this;
  643. var d = this.opts.delimiter;
  644. var newLineCount = 0;
  645. newLineCount = (line.split('\n').length - 1);
  646. switch (line) {
  647. case '<' + d:
  648. case '<' + d + '_':
  649. this.mode = Template.modes.EVAL;
  650. break;
  651. case '<' + d + '=':
  652. this.mode = Template.modes.ESCAPED;
  653. break;
  654. case '<' + d + '-':
  655. this.mode = Template.modes.RAW;
  656. break;
  657. case '<' + d + '#':
  658. this.mode = Template.modes.COMMENT;
  659. break;
  660. case '<' + d + d:
  661. this.mode = Template.modes.LITERAL;
  662. this.source += ' ; __append("' + line.replace('<' + d + d, '<' + d) + '")' + '\n';
  663. break;
  664. case d + d + '>':
  665. this.mode = Template.modes.LITERAL;
  666. this.source += ' ; __append("' + line.replace(d + d + '>', d + '>') + '")' + '\n';
  667. break;
  668. case d + '>':
  669. case '-' + d + '>':
  670. case '_' + d + '>':
  671. if (this.mode == Template.modes.LITERAL) {
  672. this._addOutput(line);
  673. }
  674. this.mode = null;
  675. this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
  676. break;
  677. default:
  678. // In script mode, depends on type of tag
  679. if (this.mode) {
  680. // If '//' is found without a line break, add a line break.
  681. switch (this.mode) {
  682. case Template.modes.EVAL:
  683. case Template.modes.ESCAPED:
  684. case Template.modes.RAW:
  685. if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
  686. line += '\n';
  687. }
  688. }
  689. switch (this.mode) {
  690. // Just executing code
  691. case Template.modes.EVAL:
  692. this.source += ' ; ' + line + '\n';
  693. break;
  694. // Exec, esc, and output
  695. case Template.modes.ESCAPED:
  696. this.source += ' ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';
  697. break;
  698. // Exec and output
  699. case Template.modes.RAW:
  700. this.source += ' ; __append(' + stripSemi(line) + ')' + '\n';
  701. break;
  702. case Template.modes.COMMENT:
  703. // Do nothing
  704. break;
  705. // Literal <%% mode, append as raw output
  706. case Template.modes.LITERAL:
  707. this._addOutput(line);
  708. break;
  709. }
  710. }
  711. // In string mode, just add the output
  712. else {
  713. this._addOutput(line);
  714. }
  715. }
  716. if (self.opts.compileDebug && newLineCount) {
  717. this.currentLine += newLineCount;
  718. this.source += ' ; __line = ' + this.currentLine + '\n';
  719. }
  720. }
  721. };
  722. /**
  723. * Escape characters reserved in XML.
  724. *
  725. * This is simply an export of {@link module:utils.escapeXML}.
  726. *
  727. * If `markup` is `undefined` or `null`, the empty string is returned.
  728. *
  729. * @param {String} markup Input string
  730. * @return {String} Escaped string
  731. * @public
  732. * @func
  733. * */
  734. exports.escapeXML = utils.escapeXML;
  735. /**
  736. * Express.js support.
  737. *
  738. * This is an alias for {@link module:ejs.renderFile}, in order to support
  739. * Express.js out-of-the-box.
  740. *
  741. * @func
  742. */
  743. exports.__express = exports.renderFile;
  744. // Add require support
  745. /* istanbul ignore else */
  746. if (require.extensions) {
  747. require.extensions['.ejs'] = function (module, flnm) {
  748. var filename = flnm || /* istanbul ignore next */ module.filename;
  749. var options = {
  750. filename: filename,
  751. client: true
  752. };
  753. var template = fileLoader(filename).toString();
  754. var fn = exports.compile(template, options);
  755. module._compile('module.exports = ' + fn.toString() + ';', filename);
  756. };
  757. }
  758. /**
  759. * Version of EJS.
  760. *
  761. * @readonly
  762. * @type {String}
  763. * @public
  764. */
  765. exports.VERSION = _VERSION_STRING;
  766. /**
  767. * Name for detection of EJS.
  768. *
  769. * @readonly
  770. * @type {String}
  771. * @public
  772. */
  773. exports.name = _NAME;
  774. /* istanbul ignore if */
  775. if (typeof window != 'undefined') {
  776. window.ejs = exports;
  777. }
  778. },{"../package.json":6,"./utils":2,"fs":3,"path":4}],2:[function(require,module,exports){
  779. /*
  780. * EJS Embedded JavaScript templates
  781. * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
  782. *
  783. * Licensed under the Apache License, Version 2.0 (the "License");
  784. * you may not use this file except in compliance with the License.
  785. * You may obtain a copy of the License at
  786. *
  787. * http://www.apache.org/licenses/LICENSE-2.0
  788. *
  789. * Unless required by applicable law or agreed to in writing, software
  790. * distributed under the License is distributed on an "AS IS" BASIS,
  791. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  792. * See the License for the specific language governing permissions and
  793. * limitations under the License.
  794. *
  795. */
  796. /**
  797. * Private utility functions
  798. * @module utils
  799. * @private
  800. */
  801. 'use strict';
  802. var regExpChars = /[|\\{}()[\]^$+*?.]/g;
  803. /**
  804. * Escape characters reserved in regular expressions.
  805. *
  806. * If `string` is `undefined` or `null`, the empty string is returned.
  807. *
  808. * @param {String} string Input string
  809. * @return {String} Escaped string
  810. * @static
  811. * @private
  812. */
  813. exports.escapeRegExpChars = function (string) {
  814. // istanbul ignore if
  815. if (!string) {
  816. return '';
  817. }
  818. return String(string).replace(regExpChars, '\\$&');
  819. };
  820. var _ENCODE_HTML_RULES = {
  821. '&': '&amp;',
  822. '<': '&lt;',
  823. '>': '&gt;',
  824. '"': '&#34;',
  825. "'": '&#39;'
  826. };
  827. var _MATCH_HTML = /[&<>\'"]/g;
  828. function encode_char(c) {
  829. return _ENCODE_HTML_RULES[c] || c;
  830. }
  831. /**
  832. * Stringified version of constants used by {@link module:utils.escapeXML}.
  833. *
  834. * It is used in the process of generating {@link ClientFunction}s.
  835. *
  836. * @readonly
  837. * @type {String}
  838. */
  839. var escapeFuncStr =
  840. 'var _ENCODE_HTML_RULES = {\n'
  841. + ' "&": "&amp;"\n'
  842. + ' , "<": "&lt;"\n'
  843. + ' , ">": "&gt;"\n'
  844. + ' , \'"\': "&#34;"\n'
  845. + ' , "\'": "&#39;"\n'
  846. + ' }\n'
  847. + ' , _MATCH_HTML = /[&<>\'"]/g;\n'
  848. + 'function encode_char(c) {\n'
  849. + ' return _ENCODE_HTML_RULES[c] || c;\n'
  850. + '};\n';
  851. /**
  852. * Escape characters reserved in XML.
  853. *
  854. * If `markup` is `undefined` or `null`, the empty string is returned.
  855. *
  856. * @implements {EscapeCallback}
  857. * @param {String} markup Input string
  858. * @return {String} Escaped string
  859. * @static
  860. * @private
  861. */
  862. exports.escapeXML = function (markup) {
  863. return markup == undefined
  864. ? ''
  865. : String(markup)
  866. .replace(_MATCH_HTML, encode_char);
  867. };
  868. exports.escapeXML.toString = function () {
  869. return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
  870. };
  871. /**
  872. * Naive copy of properties from one object to another.
  873. * Does not recurse into non-scalar properties
  874. * Does not check to see if the property has a value before copying
  875. *
  876. * @param {Object} to Destination object
  877. * @param {Object} from Source object
  878. * @return {Object} Destination object
  879. * @static
  880. * @private
  881. */
  882. exports.shallowCopy = function (to, from) {
  883. from = from || {};
  884. for (var p in from) {
  885. to[p] = from[p];
  886. }
  887. return to;
  888. };
  889. /**
  890. * Naive copy of a list of key names, from one object to another.
  891. * Only copies property if it is actually defined
  892. * Does not recurse into non-scalar properties
  893. *
  894. * @param {Object} to Destination object
  895. * @param {Object} from Source object
  896. * @param {Array} list List of properties to copy
  897. * @return {Object} Destination object
  898. * @static
  899. * @private
  900. */
  901. exports.shallowCopyFromList = function (to, from, list) {
  902. for (var i = 0; i < list.length; i++) {
  903. var p = list[i];
  904. if (typeof from[p] != 'undefined') {
  905. to[p] = from[p];
  906. }
  907. }
  908. return to;
  909. };
  910. /**
  911. * Simple in-process cache implementation. Does not implement limits of any
  912. * sort.
  913. *
  914. * @implements Cache
  915. * @static
  916. * @private
  917. */
  918. exports.cache = {
  919. _data: {},
  920. set: function (key, val) {
  921. this._data[key] = val;
  922. },
  923. get: function (key) {
  924. return this._data[key];
  925. },
  926. reset: function () {
  927. this._data = {};
  928. }
  929. };
  930. },{}],3:[function(require,module,exports){
  931. },{}],4:[function(require,module,exports){
  932. (function (process){
  933. // Copyright Joyent, Inc. and other Node contributors.
  934. //
  935. // Permission is hereby granted, free of charge, to any person obtaining a
  936. // copy of this software and associated documentation files (the
  937. // "Software"), to deal in the Software without restriction, including
  938. // without limitation the rights to use, copy, modify, merge, publish,
  939. // distribute, sublicense, and/or sell copies of the Software, and to permit
  940. // persons to whom the Software is furnished to do so, subject to the
  941. // following conditions:
  942. //
  943. // The above copyright notice and this permission notice shall be included
  944. // in all copies or substantial portions of the Software.
  945. //
  946. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  947. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  948. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  949. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  950. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  951. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  952. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  953. // resolves . and .. elements in a path array with directory names there
  954. // must be no slashes, empty elements, or device names (c:\) in the array
  955. // (so also no leading and trailing slashes - it does not distinguish
  956. // relative and absolute paths)
  957. function normalizeArray(parts, allowAboveRoot) {
  958. // if the path tries to go above the root, `up` ends up > 0
  959. var up = 0;
  960. for (var i = parts.length - 1; i >= 0; i--) {
  961. var last = parts[i];
  962. if (last === '.') {
  963. parts.splice(i, 1);
  964. } else if (last === '..') {
  965. parts.splice(i, 1);
  966. up++;
  967. } else if (up) {
  968. parts.splice(i, 1);
  969. up--;
  970. }
  971. }
  972. // if the path is allowed to go above the root, restore leading ..s
  973. if (allowAboveRoot) {
  974. for (; up--; up) {
  975. parts.unshift('..');
  976. }
  977. }
  978. return parts;
  979. }
  980. // Split a filename into [root, dir, basename, ext], unix version
  981. // 'root' is just a slash, or nothing.
  982. var splitPathRe =
  983. /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
  984. var splitPath = function(filename) {
  985. return splitPathRe.exec(filename).slice(1);
  986. };
  987. // path.resolve([from ...], to)
  988. // posix version
  989. exports.resolve = function() {
  990. var resolvedPath = '',
  991. resolvedAbsolute = false;
  992. for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  993. var path = (i >= 0) ? arguments[i] : process.cwd();
  994. // Skip empty and invalid entries
  995. if (typeof path !== 'string') {
  996. throw new TypeError('Arguments to path.resolve must be strings');
  997. } else if (!path) {
  998. continue;
  999. }
  1000. resolvedPath = path + '/' + resolvedPath;
  1001. resolvedAbsolute = path.charAt(0) === '/';
  1002. }
  1003. // At this point the path should be resolved to a full absolute path, but
  1004. // handle relative paths to be safe (might happen when process.cwd() fails)
  1005. // Normalize the path
  1006. resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
  1007. return !!p;
  1008. }), !resolvedAbsolute).join('/');
  1009. return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
  1010. };
  1011. // path.normalize(path)
  1012. // posix version
  1013. exports.normalize = function(path) {
  1014. var isAbsolute = exports.isAbsolute(path),
  1015. trailingSlash = substr(path, -1) === '/';
  1016. // Normalize the path
  1017. path = normalizeArray(filter(path.split('/'), function(p) {
  1018. return !!p;
  1019. }), !isAbsolute).join('/');
  1020. if (!path && !isAbsolute) {
  1021. path = '.';
  1022. }
  1023. if (path && trailingSlash) {
  1024. path += '/';
  1025. }
  1026. return (isAbsolute ? '/' : '') + path;
  1027. };
  1028. // posix version
  1029. exports.isAbsolute = function(path) {
  1030. return path.charAt(0) === '/';
  1031. };
  1032. // posix version
  1033. exports.join = function() {
  1034. var paths = Array.prototype.slice.call(arguments, 0);
  1035. return exports.normalize(filter(paths, function(p, index) {
  1036. if (typeof p !== 'string') {
  1037. throw new TypeError('Arguments to path.join must be strings');
  1038. }
  1039. return p;
  1040. }).join('/'));
  1041. };
  1042. // path.relative(from, to)
  1043. // posix version
  1044. exports.relative = function(from, to) {
  1045. from = exports.resolve(from).substr(1);
  1046. to = exports.resolve(to).substr(1);
  1047. function trim(arr) {
  1048. var start = 0;
  1049. for (; start < arr.length; start++) {
  1050. if (arr[start] !== '') break;
  1051. }
  1052. var end = arr.length - 1;
  1053. for (; end >= 0; end--) {
  1054. if (arr[end] !== '') break;
  1055. }
  1056. if (start > end) return [];
  1057. return arr.slice(start, end - start + 1);
  1058. }
  1059. var fromParts = trim(from.split('/'));
  1060. var toParts = trim(to.split('/'));
  1061. var length = Math.min(fromParts.length, toParts.length);
  1062. var samePartsLength = length;
  1063. for (var i = 0; i < length; i++) {
  1064. if (fromParts[i] !== toParts[i]) {
  1065. samePartsLength = i;
  1066. break;
  1067. }
  1068. }
  1069. var outputParts = [];
  1070. for (var i = samePartsLength; i < fromParts.length; i++) {
  1071. outputParts.push('..');
  1072. }
  1073. outputParts = outputParts.concat(toParts.slice(samePartsLength));
  1074. return outputParts.join('/');
  1075. };
  1076. exports.sep = '/';
  1077. exports.delimiter = ':';
  1078. exports.dirname = function(path) {
  1079. var result = splitPath(path),
  1080. root = result[0],
  1081. dir = result[1];
  1082. if (!root && !dir) {
  1083. // No dirname whatsoever
  1084. return '.';
  1085. }
  1086. if (dir) {
  1087. // It has a dirname, strip trailing slash
  1088. dir = dir.substr(0, dir.length - 1);
  1089. }
  1090. return root + dir;
  1091. };
  1092. exports.basename = function(path, ext) {
  1093. var f = splitPath(path)[2];
  1094. // TODO: make this comparison case-insensitive on windows?
  1095. if (ext && f.substr(-1 * ext.length) === ext) {
  1096. f = f.substr(0, f.length - ext.length);
  1097. }
  1098. return f;
  1099. };
  1100. exports.extname = function(path) {
  1101. return splitPath(path)[3];
  1102. };
  1103. function filter (xs, f) {
  1104. if (xs.filter) return xs.filter(f);
  1105. var res = [];
  1106. for (var i = 0; i < xs.length; i++) {
  1107. if (f(xs[i], i, xs)) res.push(xs[i]);
  1108. }
  1109. return res;
  1110. }
  1111. // String.prototype.substr - negative index don't work in IE8
  1112. var substr = 'ab'.substr(-1) === 'b'
  1113. ? function (str, start, len) { return str.substr(start, len) }
  1114. : function (str, start, len) {
  1115. if (start < 0) start = str.length + start;
  1116. return str.substr(start, len);
  1117. }
  1118. ;
  1119. }).call(this,require('_process'))
  1120. },{"_process":5}],5:[function(require,module,exports){
  1121. // shim for using process in browser
  1122. var process = module.exports = {};
  1123. // cached from whatever global is present so that test runners that stub it
  1124. // don't break things. But we need to wrap it in a try catch in case it is
  1125. // wrapped in strict mode code which doesn't define any globals. It's inside a
  1126. // function because try/catches deoptimize in certain engines.
  1127. var cachedSetTimeout;
  1128. var cachedClearTimeout;
  1129. function defaultSetTimout() {
  1130. throw new Error('setTimeout has not been defined');
  1131. }
  1132. function defaultClearTimeout () {
  1133. throw new Error('clearTimeout has not been defined');
  1134. }
  1135. (function () {
  1136. try {
  1137. if (typeof setTimeout === 'function') {
  1138. cachedSetTimeout = setTimeout;
  1139. } else {
  1140. cachedSetTimeout = defaultSetTimout;
  1141. }
  1142. } catch (e) {
  1143. cachedSetTimeout = defaultSetTimout;
  1144. }
  1145. try {
  1146. if (typeof clearTimeout === 'function') {
  1147. cachedClearTimeout = clearTimeout;
  1148. } else {
  1149. cachedClearTimeout = defaultClearTimeout;
  1150. }
  1151. } catch (e) {
  1152. cachedClearTimeout = defaultClearTimeout;
  1153. }
  1154. } ())
  1155. function runTimeout(fun) {
  1156. if (cachedSetTimeout === setTimeout) {
  1157. //normal enviroments in sane situations
  1158. return setTimeout(fun, 0);
  1159. }
  1160. // if setTimeout wasn't available but was latter defined
  1161. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  1162. cachedSetTimeout = setTimeout;
  1163. return setTimeout(fun, 0);
  1164. }
  1165. try {
  1166. // when when somebody has screwed with setTimeout but no I.E. maddness
  1167. return cachedSetTimeout(fun, 0);
  1168. } catch(e){
  1169. try {
  1170. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1171. return cachedSetTimeout.call(null, fun, 0);
  1172. } catch(e){
  1173. // 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
  1174. return cachedSetTimeout.call(this, fun, 0);
  1175. }
  1176. }
  1177. }
  1178. function runClearTimeout(marker) {
  1179. if (cachedClearTimeout === clearTimeout) {
  1180. //normal enviroments in sane situations
  1181. return clearTimeout(marker);
  1182. }
  1183. // if clearTimeout wasn't available but was latter defined
  1184. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  1185. cachedClearTimeout = clearTimeout;
  1186. return clearTimeout(marker);
  1187. }
  1188. try {
  1189. // when when somebody has screwed with setTimeout but no I.E. maddness
  1190. return cachedClearTimeout(marker);
  1191. } catch (e){
  1192. try {
  1193. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  1194. return cachedClearTimeout.call(null, marker);
  1195. } catch (e){
  1196. // 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.
  1197. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  1198. return cachedClearTimeout.call(this, marker);
  1199. }
  1200. }
  1201. }
  1202. var queue = [];
  1203. var draining = false;
  1204. var currentQueue;
  1205. var queueIndex = -1;
  1206. function cleanUpNextTick() {
  1207. if (!draining || !currentQueue) {
  1208. return;
  1209. }
  1210. draining = false;
  1211. if (currentQueue.length) {
  1212. queue = currentQueue.concat(queue);
  1213. } else {
  1214. queueIndex = -1;
  1215. }
  1216. if (queue.length) {
  1217. drainQueue();
  1218. }
  1219. }
  1220. function drainQueue() {
  1221. if (draining) {
  1222. return;
  1223. }
  1224. var timeout = runTimeout(cleanUpNextTick);
  1225. draining = true;
  1226. var len = queue.length;
  1227. while(len) {
  1228. currentQueue = queue;
  1229. queue = [];
  1230. while (++queueIndex < len) {
  1231. if (currentQueue) {
  1232. currentQueue[queueIndex].run();
  1233. }
  1234. }
  1235. queueIndex = -1;
  1236. len = queue.length;
  1237. }
  1238. currentQueue = null;
  1239. draining = false;
  1240. runClearTimeout(timeout);
  1241. }
  1242. process.nextTick = function (fun) {
  1243. var args = new Array(arguments.length - 1);
  1244. if (arguments.length > 1) {
  1245. for (var i = 1; i < arguments.length; i++) {
  1246. args[i - 1] = arguments[i];
  1247. }
  1248. }
  1249. queue.push(new Item(fun, args));
  1250. if (queue.length === 1 && !draining) {
  1251. runTimeout(drainQueue);
  1252. }
  1253. };
  1254. // v8 likes predictible objects
  1255. function Item(fun, array) {
  1256. this.fun = fun;
  1257. this.array = array;
  1258. }
  1259. Item.prototype.run = function () {
  1260. this.fun.apply(null, this.array);
  1261. };
  1262. process.title = 'browser';
  1263. process.browser = true;
  1264. process.env = {};
  1265. process.argv = [];
  1266. process.version = ''; // empty string to avoid regexp issues
  1267. process.versions = {};
  1268. function noop() {}
  1269. process.on = noop;
  1270. process.addListener = noop;
  1271. process.once = noop;
  1272. process.off = noop;
  1273. process.removeListener = noop;
  1274. process.removeAllListeners = noop;
  1275. process.emit = noop;
  1276. process.binding = function (name) {
  1277. throw new Error('process.binding is not supported');
  1278. };
  1279. process.cwd = function () { return '/' };
  1280. process.chdir = function (dir) {
  1281. throw new Error('process.chdir is not supported');
  1282. };
  1283. process.umask = function() { return 0; };
  1284. },{}],6:[function(require,module,exports){
  1285. module.exports={
  1286. "name": "ejs",
  1287. "description": "Embedded JavaScript templates",
  1288. "keywords": [
  1289. "template",
  1290. "engine",
  1291. "ejs"
  1292. ],
  1293. "version": "2.5.6",
  1294. "author": "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
  1295. "contributors": [
  1296. "Timothy Gu <timothygu99@gmail.com> (https://timothygu.github.io)"
  1297. ],
  1298. "license": "Apache-2.0",
  1299. "main": "./lib/ejs.js",
  1300. "repository": {
  1301. "type": "git",
  1302. "url": "git://github.com/mde/ejs.git"
  1303. },
  1304. "bugs": "https://github.com/mde/ejs/issues",
  1305. "homepage": "https://github.com/mde/ejs",
  1306. "dependencies": {},
  1307. "devDependencies": {
  1308. "browserify": "^13.0.1",
  1309. "eslint": "^3.0.0",
  1310. "git-directory-deploy": "^1.5.1",
  1311. "istanbul": "~0.4.3",
  1312. "jake": "^8.0.0",
  1313. "jsdoc": "^3.4.0",
  1314. "lru-cache": "^4.0.1",
  1315. "mocha": "^3.0.2",
  1316. "uglify-js": "^2.6.2"
  1317. },
  1318. "engines": {
  1319. "node": ">=0.10.0"
  1320. },
  1321. "scripts": {
  1322. "test": "jake test",
  1323. "lint": "eslint \"**/*.js\" Jakefile",
  1324. "coverage": "istanbul cover node_modules/mocha/bin/_mocha",
  1325. "doc": "jake doc",
  1326. "devdoc": "jake doc[dev]"
  1327. }
  1328. }
  1329. },{}]},{},[1])(1)
  1330. });