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

tripartite

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tripartite - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

1

calculate-relative-path.js
var calculateRelativePath = function(parentPath, currentPath) {
debugger
if(!parentPath) {

@@ -4,0 +3,0 @@ return currentPath

4

package.json
{
"name": "tripartite",
"version": "1.0.12",
"version": "1.0.13",
"description": "A simple and fast javascript templating library",

@@ -8,3 +8,3 @@ "main": "tripartite.js",

"test": "node_modules/mocha/bin/mocha",
"testDebug": "node_modules/mocha/bin/mocha --inspect --debug-brk",
"testDebug": "node_modules/mocha/bin/mocha --inspect --inspect-brk",
"debug": "node --inspect --debug-brk test/test-stream-file-load-direct.js"

@@ -11,0 +11,0 @@ },

@@ -39,2 +39,15 @@ var tri = require('../helpers/tri-with-loader')

})
it("globals reference", function(done) {
var second = tri.addTemplate('second', '__num1__ __num2__ __$globals.num2__')
var first = tri.pt("__abc::second__ __$globals.num2__")
first({abc: {num1: 1, num2: 3}, num2: 2}, out, function() {
try {
assert.equal(out.getContentsAsString(), "1 3 2 2")
done()
} catch(ex) {
done(ex)
}
})
})
})

@@ -41,0 +54,0 @@ describe('missing data allows templates to continue', function() {

@@ -27,2 +27,9 @@ var tri = require('../tripartite')

it("globals reference", function() {
tri.addTemplate('second', '__num1__ __num2__ __$globals.num2__')
var first = tri.pt("__abc::second__ __$globals.num2__")
assert.equal('1 3 2 2', first({abc: {num1: 1, num2: 3}, num2: 2}))
})
it("blank data", function() {

@@ -29,0 +36,0 @@ var blankData = tri.pt('some __::wonder__')

@@ -56,8 +56,8 @@

var oldFun = template
template = function(cc) {
if(arguments.length > 1) {
template = function(cc, globalData) {
if(arguments.length > 1 && arguments[1] && arguments[1].write) {
template.write.apply(this, arguments)
}
else {
return oldFun(cc)
return oldFun(cc, globalData)
}

@@ -175,8 +175,8 @@ }

el.templateMeta = templateMeta
var f = function(cc) {
if(arguments.length > 1) {
var f = function(cc, globalData) {
if(arguments.length > 1 && arguments[1] && arguments[1].write) {
el.write.apply(el, arguments)
}
else {
return el.run(cc);
return el.run(cc, globalData);
}

@@ -186,4 +186,4 @@ }

f.write = function(cc, stream, callback) {
el.write(cc, stream, callback)
f.write = function(cc, stream, callback, globalData) {
el.write(cc, stream, callback, globalData)
}

@@ -194,9 +194,9 @@ return f

ae.prototype.run = function(/* current context */cc) {
ae.prototype.run = function(/* current context */cc, globalData) {
/* run template */
var rt = false;
/* evaluated data */
this.ed = this.edse(cc);
this.ed = this.edse(cc, globalData);
if(this.ce) {
rt = this.eic(cc, this.ce);
rt = this.eic(cc, this.ce, globalData);
}

@@ -222,3 +222,3 @@ else {

if(at.charAt(0) == '$') {
at = this.eic(cc, at.substring(1));
at = this.eic(cc, at.substring(1), globalData);
}

@@ -238,3 +238,3 @@ if(!at) {

for(var i = 0; i < this.ed.length; i++) {
r += this.getTemplate(at)(this.ed[i]);
r += this.getTemplate(at)(this.ed[i], globalData || cc);
}

@@ -244,3 +244,3 @@ return r;

else {
return this.getTemplate(at)(this.ed);
return this.getTemplate(at)(this.ed, globalData || cc);
}

@@ -251,9 +251,9 @@ }

ae.prototype.write = function(/* current context */cc, stream, callback) {
ae.prototype.write = function(/* current context */cc, stream, callback, globalData) {
/* run template */
var rt = false;
/* evaluated data */
this.ed = this.edse(cc);
this.ed = this.edse(cc, globalData);
if(this.ce) {
rt = this.eic(cc, this.ce);
rt = this.eic(cc, this.ce, globalData);
}

@@ -279,3 +279,3 @@ else {

if(at.charAt(0) == '$') {
at = this.eic(cc, at.substring(1));
at = this.eic(cc, at.substring(1), globalData);
}

@@ -314,3 +314,3 @@ if(!at) {

}
})
}, globalData || cc)
}

@@ -348,3 +348,3 @@ else {

/* evaluate data selector expression */
ae.prototype.edse = function(cc) {
ae.prototype.edse = function(cc, globalData) {
if(!this.dse) {

@@ -356,21 +356,26 @@ return null;

}
return this.eic(cc, this.dse);
return this.eic(cc, this.dse, globalData);
};
/* evaluate in context */
ae.prototype.eic = function(cc, ex) {
ae.prototype.eic = function(cc, ex, globalData) {
cc = cc || {};
return this.eicwt.call(cc, cc, ex, this.tripartite.dataFunctions);
return this.eicwt.call(cc, cc, ex, this.tripartite.dataFunctions, globalData);
};
/* Evaluate in context having been called so that this === cc (current context */
ae.prototype.eicwt = function(cc, ex, dataFunctions) {
ae.prototype.eicwt = function(cc, ex, dataFunctions, globalData) {
dataFunctions = dataFunctions || {}
globalData = globalData || cc || {}
with (dataFunctions) {
with (cc) {
try {
return eval(ex);
} catch(e) {
return null;
with ({
'$globals': globalData
}) {
with (dataFunctions) {
with (cc) {
try {
return eval(ex);
} catch(e) {
return null;
}
}

@@ -399,4 +404,4 @@ }

var t = function(cc) {
if(arguments.length > 1) {
var t = function(cc, globalData) {
if(arguments.length > 1 && arguments[1] && arguments[1].write) {
t.write.apply(t, arguments)

@@ -411,3 +416,3 @@ }

else {
r += pt[i](cc);
r += pt[i](cc, globalData);
}

@@ -421,3 +426,3 @@ }

t.write = function(cc, stream, callback) {
t.write = function(cc, stream, callback, globalData) {
var consumed = cloneArray(pt)

@@ -457,3 +462,3 @@ var lastError

}
})
}, globalData)
}

@@ -460,0 +465,0 @@ }

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