Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot

Package Overview
Dependencies
Maintainers
0
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

70

doT.js
// doT.js
// (c) 2011, Laura Doktorova
// 2011, Laura Doktorova
// https://github.com/olado/doT
//
// doT is an extraction and slight modification of an excellent
// templating function from jQote2.js (jQuery plugin) by aefxx
// (http://aefxx.com/jquery-plugins/jqote2/).
// doT is a blend of templating functions from jQote2.js
// (jQuery plugin) by aefxx (http://aefxx.com/jquery-plugins/jqote2/)
// and underscore.js (http://documentcloud.github.com/underscore/)
//
// Modifications:
// 1. nodejs support
// 2. allow for custom template markers
// 3. only allow direct invocation of the compiled function
// Licensed under the MIT license.
//
// Licensed under the MIT license.
(function() {
var doT = { version : '0.1.2' };
var doT = { version : '0.1.3' };

@@ -26,27 +21,38 @@ if (typeof module !== 'undefined' && module.exports) {

doT.templateSettings = {
begin : '{{',
end : '}}',
varname : 'it'
evaluate : /\{\{([\s\S]+?)\}\}/g,
interpolate : /\{\{=([\s\S]+?)\}\}/g,
encode : /\{\{!([\s\S]+?)\}\}/g,
defines: /\{\{#([\s\S]+?)\}\}/g,
varname : 'it',
strip : true
};
doT.template = function(tmpl, conf) {
conf = conf || doT.templateSettings;
var str = '', tb = conf.begin, te = conf.end, m, l,
arr = tmpl.replace(/\s*<!\[CDATA\[\s*|\s*\]\]>\s*|[\r\n\t]|(\/\*[\s\S]*?\*\/)/g, '')
.split(tb).join(te +'\x1b')
.split(te);
doT.template = function(tmpl, c, defs) {
c = c || doT.templateSettings;
var str = ("var out='" +
((c.strip) ? tmpl.replace(/\s*<!\[CDATA\[\s*|\s*\]\]>\s*|[\r\n\t]|(\/\*[\s\S]*?\*\/)/g, ''):
tmpl)
.replace(c.defines, function(match, code) {
return eval(code.replace(/[\r\t\n]/g, ' '));
})
.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(c.interpolate, function(match, code) {
return "';out+=" + code.replace(/\\'/g, "'").replace(/\\\\/g,"\\").replace(/[\r\t\n]/g, ' ') + ";out+='";
})
.replace(c.encode, function(match, code) {
return "';out+=(" + code.replace(/\\'/g, "'").replace(/\\\\/g, "\\").replace(/[\r\t\n]/g, ' ') + ").toString().replace(/&(?!\\w+;)/g, '&#38;').split('<').join('&#60;').split('>').join('&#62;').split('" + '"' + "').join('&#34;').split(" + '"' + "'" + '"' + ").join('&#39;').split('/').join('&#x2F;');out+='";
})
.replace(c.evaluate, function(match, code) {
return "';" + code.replace(/\\'/g, "'").replace(/\\\\/g,"\\").replace(/[\r\t\n]/g, ' ') + "out+='";
})
+ "';return out;")
.replace(/\n/g, '\\n')
.replace(/\t/g, '\\t')
.replace(/\r/g, '\\r')
.split("out+='';").join('')
.split('var out="";out+=').join('var out=');
for (m=0,l=arr.length; m < l; m++) {
str += arr[m].charAt(0) !== '\x1b' ?
"out+='" + arr[m].replace(/(\\|["'])/g, '\\$1') + "'" : (arr[m].charAt(1) === '=' ?
';out+=(' + arr[m].substr(2) + ');' : (arr[m].charAt(1) === '!' ?
';out+=(' + arr[m].substr(2) + ").toString().replace(/&(?!\\w+;)/g, '&#38;').split('<').join('&#60;').split('>').join('&#62;').split('" + '"' + "').join('&#34;').split(" + '"' + "'" + '"' + ").join('&#39;');" : ';' + arr[m].substr(1)));
}
str = ('var out="";'+str+';return out;')
.split("out+='';").join('')
.split('var out="";out+=').join('var out=');
try {
return new Function(conf.varname, str);
return new Function(c.varname, str);
} catch (e) {

@@ -53,0 +59,0 @@ if (typeof console !== 'undefined') console.log("Could not create a template function: " + str);

@@ -7,8 +7,10 @@ (function() {

doT.templateSettings = {
begin : '<?',
end : '?>',
varname : 'it'
evaluate : /\<\?([\s\S]+?)\?\>/g,
interpolate : /\<\?=([\s\S]+?)\?\>/g,
varname : 'it',
strip: true
};
var doTCompiled = doT.template(snippet);

@@ -15,0 +17,0 @@

@@ -10,3 +10,3 @@ {

],
"version": "0.1.2",
"version": "0.1.3",
"main": "doT",

@@ -13,0 +13,0 @@ "homepage": "http://github.com/olado/doT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc