12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736 |
- (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){
- 'use strict';
- var fs = require('fs');
- var path = require('path');
- var utils = require('./utils');
- var scopeOptionWarned = false;
- var _VERSION_STRING = require('../package.json').version;
- var _DEFAULT_OPEN_DELIMITER = '<';
- var _DEFAULT_CLOSE_DELIMITER = '>';
- var _DEFAULT_DELIMITER = '%';
- var _DEFAULT_LOCALS_NAME = 'locals';
- var _NAME = 'ejs';
- var _REGEX_STRING = '(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)';
- var _OPTS_PASSABLE_WITH_DATA = ['delimiter', 'scope', 'context', 'debug', 'compileDebug',
- 'client', '_with', 'rmWhitespace', 'strict', 'filename', 'async'];
- var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
- var _BOM = /^\uFEFF/;
- var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
- exports.cache = utils.cache;
- exports.fileLoader = fs.readFileSync;
- exports.localsName = _DEFAULT_LOCALS_NAME;
- exports.promiseImpl = (new Function('return this;'))().Promise;
- exports.resolveInclude = function(name, filename, isDir) {
- var dirname = path.dirname;
- var extname = path.extname;
- var resolve = path.resolve;
- var includePath = resolve(isDir ? filename : dirname(filename), name);
- var ext = extname(name);
- if (!ext) {
- includePath += '.ejs';
- }
- return includePath;
- };
- function resolvePaths(name, paths) {
- var filePath;
- if (paths.some(function (v) {
- filePath = exports.resolveInclude(name, v, true);
- return fs.existsSync(filePath);
- })) {
- return filePath;
- }
- }
- function getIncludePath(path, options) {
- var includePath;
- var filePath;
- var views = options.views;
- var match = /^[A-Za-z]+:\\|^\//.exec(path);
-
- if (match && match.length) {
- path = path.replace(/^\/*/, '');
- if (Array.isArray(options.root)) {
- includePath = resolvePaths(path, options.root);
- } else {
- includePath = exports.resolveInclude(path, options.root || '/', true);
- }
- }
-
- else {
-
- if (options.filename) {
- filePath = exports.resolveInclude(path, options.filename);
- if (fs.existsSync(filePath)) {
- includePath = filePath;
- }
- }
-
- if (!includePath && Array.isArray(views)) {
- includePath = resolvePaths(path, views);
- }
- if (!includePath && typeof options.includer !== 'function') {
- throw new Error('Could not find the include file "' +
- options.escapeFunction(path) + '"');
- }
- }
- return includePath;
- }
- function handleCache(options, template) {
- var func;
- var filename = options.filename;
- var hasTemplate = arguments.length > 1;
- if (options.cache) {
- if (!filename) {
- throw new Error('cache option requires a filename');
- }
- func = exports.cache.get(filename);
- if (func) {
- return func;
- }
- if (!hasTemplate) {
- template = fileLoader(filename).toString().replace(_BOM, '');
- }
- }
- else if (!hasTemplate) {
-
- if (!filename) {
- throw new Error('Internal EJS error: no file name or template '
- + 'provided');
- }
- template = fileLoader(filename).toString().replace(_BOM, '');
- }
- func = exports.compile(template, options);
- if (options.cache) {
- exports.cache.set(filename, func);
- }
- return func;
- }
- function tryHandleCache(options, data, cb) {
- var result;
- if (!cb) {
- if (typeof exports.promiseImpl == 'function') {
- return new exports.promiseImpl(function (resolve, reject) {
- try {
- result = handleCache(options)(data);
- resolve(result);
- }
- catch (err) {
- reject(err);
- }
- });
- }
- else {
- throw new Error('Please provide a callback function');
- }
- }
- else {
- try {
- result = handleCache(options)(data);
- }
- catch (err) {
- return cb(err);
- }
- cb(null, result);
- }
- }
- function fileLoader(filePath){
- return exports.fileLoader(filePath);
- }
- function includeFile(path, options) {
- var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
- opts.filename = getIncludePath(path, opts);
- if (typeof options.includer === 'function') {
- var includerResult = options.includer(path, opts.filename);
- if (includerResult) {
- if (includerResult.filename) {
- opts.filename = includerResult.filename;
- }
- if (includerResult.template) {
- return handleCache(opts, includerResult.template);
- }
- }
- }
- return handleCache(opts);
- }
- function rethrow(err, str, flnm, lineno, esc) {
- var lines = str.split('\n');
- var start = Math.max(lineno - 3, 0);
- var end = Math.min(lines.length, lineno + 3);
- var filename = esc(flnm);
-
- var context = lines.slice(start, end).map(function (line, i){
- var curr = i + start + 1;
- return (curr == lineno ? ' >> ' : ' ')
- + curr
- + '| '
- + line;
- }).join('\n');
-
- err.path = filename;
- err.message = (filename || 'ejs') + ':'
- + lineno + '\n'
- + context + '\n\n'
- + err.message;
- throw err;
- }
- function stripSemi(str){
- return str.replace(/;(\s*$)/, '$1');
- }
- exports.compile = function compile(template, opts) {
- var templ;
-
-
-
- if (opts && opts.scope) {
- if (!scopeOptionWarned){
- console.warn('`scope` option is deprecated and will be removed in EJS 3');
- scopeOptionWarned = true;
- }
- if (!opts.context) {
- opts.context = opts.scope;
- }
- delete opts.scope;
- }
- templ = new Template(template, opts);
- return templ.compile();
- };
- exports.render = function (template, d, o) {
- var data = d || utils.createNullProtoObjWherePossible();
- var opts = o || utils.createNullProtoObjWherePossible();
-
-
- if (arguments.length == 2) {
- utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
- }
- return handleCache(opts, template)(data);
- };
- exports.renderFile = function () {
- var args = Array.prototype.slice.call(arguments);
- var filename = args.shift();
- var cb;
- var opts = {filename: filename};
- var data;
- var viewOpts;
-
- if (typeof arguments[arguments.length - 1] == 'function') {
- cb = args.pop();
- }
-
- if (args.length) {
-
- data = args.shift();
-
- if (args.length) {
-
- utils.shallowCopy(opts, args.pop());
- }
-
- else {
-
- if (data.settings) {
-
- if (data.settings.views) {
- opts.views = data.settings.views;
- }
- if (data.settings['view cache']) {
- opts.cache = true;
- }
-
-
- viewOpts = data.settings['view options'];
- if (viewOpts) {
- utils.shallowCopy(opts, viewOpts);
- }
- }
-
-
-
- utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
- }
- opts.filename = filename;
- }
- else {
- data = utils.createNullProtoObjWherePossible();
- }
- return tryHandleCache(opts, data, cb);
- };
- exports.Template = Template;
- exports.clearCache = function () {
- exports.cache.reset();
- };
- function Template(text, opts) {
- opts = opts || utils.createNullProtoObjWherePossible();
- var options = utils.createNullProtoObjWherePossible();
- this.templateText = text;
-
- this.mode = null;
- this.truncate = false;
- this.currentLine = 1;
- this.source = '';
- options.client = opts.client || false;
- options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
- options.compileDebug = opts.compileDebug !== false;
- options.debug = !!opts.debug;
- options.filename = opts.filename;
- options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
- options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
- options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
- options.strict = opts.strict || false;
- options.context = opts.context;
- options.cache = opts.cache || false;
- options.rmWhitespace = opts.rmWhitespace;
- options.root = opts.root;
- options.includer = opts.includer;
- options.outputFunctionName = opts.outputFunctionName;
- options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
- options.views = opts.views;
- options.async = opts.async;
- options.destructuredLocals = opts.destructuredLocals;
- options.legacyInclude = typeof opts.legacyInclude != 'undefined' ? !!opts.legacyInclude : true;
- if (options.strict) {
- options._with = false;
- }
- else {
- options._with = typeof opts._with != 'undefined' ? opts._with : true;
- }
- this.opts = options;
- this.regex = this.createRegex();
- }
- Template.modes = {
- EVAL: 'eval',
- ESCAPED: 'escaped',
- RAW: 'raw',
- COMMENT: 'comment',
- LITERAL: 'literal'
- };
- Template.prototype = {
- createRegex: function () {
- var str = _REGEX_STRING;
- var delim = utils.escapeRegExpChars(this.opts.delimiter);
- var open = utils.escapeRegExpChars(this.opts.openDelimiter);
- var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
- str = str.replace(/%/g, delim)
- .replace(/</g, open)
- .replace(/>/g, close);
- return new RegExp(str);
- },
- compile: function () {
-
- var src;
-
- var fn;
- var opts = this.opts;
- var prepended = '';
- var appended = '';
-
- var escapeFn = opts.escapeFunction;
-
- var ctor;
-
- var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : 'undefined';
- if (!this.source) {
- this.generateSource();
- prepended +=
- ' var __output = "";\n' +
- ' function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
- if (opts.outputFunctionName) {
- if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
- throw new Error('outputFunctionName is not a valid JS identifier.');
- }
- prepended += ' var ' + opts.outputFunctionName + ' = __append;' + '\n';
- }
- if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
- throw new Error('localsName is not a valid JS identifier.');
- }
- if (opts.destructuredLocals && opts.destructuredLocals.length) {
- var destructuring = ' var __locals = (' + opts.localsName + ' || {}),\n';
- for (var i = 0; i < opts.destructuredLocals.length; i++) {
- var name = opts.destructuredLocals[i];
- if (!_JS_IDENTIFIER.test(name)) {
- throw new Error('destructuredLocals[' + i + '] is not a valid JS identifier.');
- }
- if (i > 0) {
- destructuring += ',\n ';
- }
- destructuring += name + ' = __locals.' + name;
- }
- prepended += destructuring + ';\n';
- }
- if (opts._with !== false) {
- prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
- appended += ' }' + '\n';
- }
- appended += ' return __output;' + '\n';
- this.source = prepended + this.source + appended;
- }
- if (opts.compileDebug) {
- src = 'var __line = 1' + '\n'
- + ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
- + ' , __filename = ' + sanitizedFilename + ';' + '\n'
- + 'try {' + '\n'
- + this.source
- + '} catch (e) {' + '\n'
- + ' rethrow(e, __lines, __filename, __line, escapeFn);' + '\n'
- + '}' + '\n';
- }
- else {
- src = this.source;
- }
- if (opts.client) {
- src = 'escapeFn = escapeFn || ' + escapeFn.toString() + ';' + '\n' + src;
- if (opts.compileDebug) {
- src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
- }
- }
- if (opts.strict) {
- src = '"use strict";\n' + src;
- }
- if (opts.debug) {
- console.log(src);
- }
- if (opts.compileDebug && opts.filename) {
- src = src + '\n'
- + '//# sourceURL=' + sanitizedFilename + '\n';
- }
- try {
- if (opts.async) {
-
-
- try {
- ctor = (new Function('return (async function(){}).constructor;'))();
- }
- catch(e) {
- if (e instanceof SyntaxError) {
- throw new Error('This environment does not support async/await');
- }
- else {
- throw e;
- }
- }
- }
- else {
- ctor = Function;
- }
- fn = new ctor(opts.localsName + ', escapeFn, include, rethrow', src);
- }
- catch(e) {
-
- if (e instanceof SyntaxError) {
- if (opts.filename) {
- e.message += ' in ' + opts.filename;
- }
- e.message += ' while compiling ejs\n\n';
- e.message += 'If the above error is not helpful, you may want to try EJS-Lint:\n';
- e.message += 'https://github.com/RyanZim/EJS-Lint';
- if (!opts.async) {
- e.message += '\n';
- e.message += 'Or, if you meant to create an async function, pass `async: true` as an option.';
- }
- }
- throw e;
- }
-
-
-
- var returnedFn = opts.client ? fn : function anonymous(data) {
- var include = function (path, includeData) {
- var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
- if (includeData) {
- d = utils.shallowCopy(d, includeData);
- }
- return includeFile(path, opts)(d);
- };
- return fn.apply(opts.context,
- [data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]);
- };
- if (opts.filename && typeof Object.defineProperty === 'function') {
- var filename = opts.filename;
- var basename = path.basename(filename, path.extname(filename));
- try {
- Object.defineProperty(returnedFn, 'name', {
- value: basename,
- writable: false,
- enumerable: false,
- configurable: true
- });
- } catch (e) {}
- }
- return returnedFn;
- },
- generateSource: function () {
- var opts = this.opts;
- if (opts.rmWhitespace) {
-
-
- this.templateText =
- this.templateText.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
- }
-
- this.templateText =
- this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
- var self = this;
- var matches = this.parseTemplateText();
- var d = this.opts.delimiter;
- var o = this.opts.openDelimiter;
- var c = this.opts.closeDelimiter;
- if (matches && matches.length) {
- matches.forEach(function (line, index) {
- var closing;
-
-
-
-
- if ( line.indexOf(o + d) === 0
- && line.indexOf(o + d + d) !== 0) {
- closing = matches[index + 2];
- if (!(closing == d + c || closing == '-' + d + c || closing == '_' + d + c)) {
- throw new Error('Could not find matching close tag for "' + line + '".');
- }
- }
- self.scanLine(line);
- });
- }
- },
- parseTemplateText: function () {
- var str = this.templateText;
- var pat = this.regex;
- var result = pat.exec(str);
- var arr = [];
- var firstPos;
- while (result) {
- firstPos = result.index;
- if (firstPos !== 0) {
- arr.push(str.substring(0, firstPos));
- str = str.slice(firstPos);
- }
- arr.push(result[0]);
- str = str.slice(result[0].length);
- result = pat.exec(str);
- }
- if (str) {
- arr.push(str);
- }
- return arr;
- },
- _addOutput: function (line) {
- if (this.truncate) {
-
-
-
-
-
- line = line.replace(/^(?:\r\n|\r|\n)/, '');
- this.truncate = false;
- }
- if (!line) {
- return line;
- }
-
- line = line.replace(/\\/g, '\\\\');
-
- line = line.replace(/\n/g, '\\n');
- line = line.replace(/\r/g, '\\r');
-
-
- line = line.replace(/"/g, '\\"');
- this.source += ' ; __append("' + line + '")' + '\n';
- },
- scanLine: function (line) {
- var self = this;
- var d = this.opts.delimiter;
- var o = this.opts.openDelimiter;
- var c = this.opts.closeDelimiter;
- var newLineCount = 0;
- newLineCount = (line.split('\n').length - 1);
- switch (line) {
- case o + d:
- case o + d + '_':
- this.mode = Template.modes.EVAL;
- break;
- case o + d + '=':
- this.mode = Template.modes.ESCAPED;
- break;
- case o + d + '-':
- this.mode = Template.modes.RAW;
- break;
- case o + d + '#':
- this.mode = Template.modes.COMMENT;
- break;
- case o + d + d:
- this.mode = Template.modes.LITERAL;
- this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")' + '\n';
- break;
- case d + d + c:
- this.mode = Template.modes.LITERAL;
- this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")' + '\n';
- break;
- case d + c:
- case '-' + d + c:
- case '_' + d + c:
- if (this.mode == Template.modes.LITERAL) {
- this._addOutput(line);
- }
- this.mode = null;
- this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
- break;
- default:
-
- if (this.mode) {
-
- switch (this.mode) {
- case Template.modes.EVAL:
- case Template.modes.ESCAPED:
- case Template.modes.RAW:
- if (line.lastIndexOf('//') > line.lastIndexOf('\n')) {
- line += '\n';
- }
- }
- switch (this.mode) {
-
- case Template.modes.EVAL:
- this.source += ' ; ' + line + '\n';
- break;
-
- case Template.modes.ESCAPED:
- this.source += ' ; __append(escapeFn(' + stripSemi(line) + '))' + '\n';
- break;
-
- case Template.modes.RAW:
- this.source += ' ; __append(' + stripSemi(line) + ')' + '\n';
- break;
- case Template.modes.COMMENT:
-
- break;
-
- case Template.modes.LITERAL:
- this._addOutput(line);
- break;
- }
- }
-
- else {
- this._addOutput(line);
- }
- }
- if (self.opts.compileDebug && newLineCount) {
- this.currentLine += newLineCount;
- this.source += ' ; __line = ' + this.currentLine + '\n';
- }
- }
- };
- exports.escapeXML = utils.escapeXML;
- exports.__express = exports.renderFile;
- exports.VERSION = _VERSION_STRING;
- exports.name = _NAME;
- if (typeof window != 'undefined') {
- window.ejs = exports;
- }
- },{"../package.json":6,"./utils":2,"fs":3,"path":4}],2:[function(require,module,exports){
- 'use strict';
- var regExpChars = /[|\\{}()[\]^$+*?.]/g;
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- var hasOwn = function (obj, key) { return hasOwnProperty.apply(obj, [key]); };
- exports.escapeRegExpChars = function (string) {
-
- if (!string) {
- return '';
- }
- return String(string).replace(regExpChars, '\\$&');
- };
- var _ENCODE_HTML_RULES = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- "'": '''
- };
- var _MATCH_HTML = /[&<>'"]/g;
- function encode_char(c) {
- return _ENCODE_HTML_RULES[c] || c;
- }
- var escapeFuncStr =
- 'var _ENCODE_HTML_RULES = {\n'
- + ' "&": "&"\n'
- + ' , "<": "<"\n'
- + ' , ">": ">"\n'
- + ' , \'"\': """\n'
- + ' , "\'": "'"\n'
- + ' }\n'
- + ' , _MATCH_HTML = /[&<>\'"]/g;\n'
- + 'function encode_char(c) {\n'
- + ' return _ENCODE_HTML_RULES[c] || c;\n'
- + '};\n';
- exports.escapeXML = function (markup) {
- return markup == undefined
- ? ''
- : String(markup)
- .replace(_MATCH_HTML, encode_char);
- };
- function escapeXMLToString() {
- return Function.prototype.toString.call(this) + ';\n' + escapeFuncStr;
- }
- try {
- if (typeof Object.defineProperty === 'function') {
-
-
-
-
- Object.defineProperty(exports.escapeXML, 'toString', { value: escapeXMLToString });
- } else {
-
- exports.escapeXML.toString = escapeXMLToString;
- }
- } catch (err) {
- console.warn('Unable to set escapeXML.toString (is the Function prototype frozen?)');
- }
- exports.shallowCopy = function (to, from) {
- from = from || {};
- if ((to !== null) && (to !== undefined)) {
- for (var p in from) {
- if (!hasOwn(from, p)) {
- continue;
- }
- if (p === '__proto__' || p === 'constructor') {
- continue;
- }
- to[p] = from[p];
- }
- }
- return to;
- };
- exports.shallowCopyFromList = function (to, from, list) {
- list = list || [];
- from = from || {};
- if ((to !== null) && (to !== undefined)) {
- for (var i = 0; i < list.length; i++) {
- var p = list[i];
- if (typeof from[p] != 'undefined') {
- if (!hasOwn(from, p)) {
- continue;
- }
- if (p === '__proto__' || p === 'constructor') {
- continue;
- }
- to[p] = from[p];
- }
- }
- }
- return to;
- };
- exports.cache = {
- _data: {},
- set: function (key, val) {
- this._data[key] = val;
- },
- get: function (key) {
- return this._data[key];
- },
- remove: function (key) {
- delete this._data[key];
- },
- reset: function () {
- this._data = {};
- }
- };
- exports.hyphenToCamel = function (str) {
- return str.replace(/-[a-z]/g, function (match) { return match[1].toUpperCase(); });
- };
- exports.createNullProtoObjWherePossible = (function () {
- if (typeof Object.create == 'function') {
- return function () {
- return Object.create(null);
- };
- }
- if (!({__proto__: null} instanceof Object)) {
- return function () {
- return {__proto__: null};
- };
- }
-
- return function () {
- return {};
- };
- })();
- },{}],3:[function(require,module,exports){
- },{}],4:[function(require,module,exports){
- (function (process){
- function normalizeArray(parts, allowAboveRoot) {
-
- var up = 0;
- for (var i = parts.length - 1; i >= 0; i--) {
- var last = parts[i];
- if (last === '.') {
- parts.splice(i, 1);
- } else if (last === '..') {
- parts.splice(i, 1);
- up++;
- } else if (up) {
- parts.splice(i, 1);
- up--;
- }
- }
-
- if (allowAboveRoot) {
- for (; up--; up) {
- parts.unshift('..');
- }
- }
- return parts;
- }
- exports.resolve = function() {
- var resolvedPath = '',
- resolvedAbsolute = false;
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
- var path = (i >= 0) ? arguments[i] : process.cwd();
-
- if (typeof path !== 'string') {
- throw new TypeError('Arguments to path.resolve must be strings');
- } else if (!path) {
- continue;
- }
- resolvedPath = path + '/' + resolvedPath;
- resolvedAbsolute = path.charAt(0) === '/';
- }
-
-
-
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
- return !!p;
- }), !resolvedAbsolute).join('/');
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
- };
- exports.normalize = function(path) {
- var isAbsolute = exports.isAbsolute(path),
- trailingSlash = substr(path, -1) === '/';
-
- path = normalizeArray(filter(path.split('/'), function(p) {
- return !!p;
- }), !isAbsolute).join('/');
- if (!path && !isAbsolute) {
- path = '.';
- }
- if (path && trailingSlash) {
- path += '/';
- }
- return (isAbsolute ? '/' : '') + path;
- };
- exports.isAbsolute = function(path) {
- return path.charAt(0) === '/';
- };
- exports.join = function() {
- var paths = Array.prototype.slice.call(arguments, 0);
- return exports.normalize(filter(paths, function(p, index) {
- if (typeof p !== 'string') {
- throw new TypeError('Arguments to path.join must be strings');
- }
- return p;
- }).join('/'));
- };
- exports.relative = function(from, to) {
- from = exports.resolve(from).substr(1);
- to = exports.resolve(to).substr(1);
- function trim(arr) {
- var start = 0;
- for (; start < arr.length; start++) {
- if (arr[start] !== '') break;
- }
- var end = arr.length - 1;
- for (; end >= 0; end--) {
- if (arr[end] !== '') break;
- }
- if (start > end) return [];
- return arr.slice(start, end - start + 1);
- }
- var fromParts = trim(from.split('/'));
- var toParts = trim(to.split('/'));
- var length = Math.min(fromParts.length, toParts.length);
- var samePartsLength = length;
- for (var i = 0; i < length; i++) {
- if (fromParts[i] !== toParts[i]) {
- samePartsLength = i;
- break;
- }
- }
- var outputParts = [];
- for (var i = samePartsLength; i < fromParts.length; i++) {
- outputParts.push('..');
- }
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
- return outputParts.join('/');
- };
- exports.sep = '/';
- exports.delimiter = ':';
- exports.dirname = function (path) {
- if (typeof path !== 'string') path = path + '';
- if (path.length === 0) return '.';
- var code = path.charCodeAt(0);
- var hasRoot = code === 47
|