New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

combyne

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

combyne - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

11

lib/index.js

@@ -36,3 +36,3 @@ var renderer = require("./renderer");

combyne.version = "0.1.0";
combyne.version = "0.1.1";
combyne.prototype = {

@@ -45,3 +45,3 @@

if (!self.template || !self.context) {
throw new Error("Missing template or context");
//throw new Error("Missing template or context");
}

@@ -79,1 +79,8 @@

module.exports = combyne;
//Express Support
module.exports.compile = function(markup) {
return function(locals) {
return combyne(markup, locals).render();
};
}

43

lib/renderer.js

@@ -63,3 +63,4 @@ var tokenizer = function() {

if (filter == null) {
throw new Error("Filter " + method + " not found");
filter = function() { return obj; }
//throw new Error("Filter " + method + " not found");
}

@@ -203,4 +204,4 @@

function runPartial(self, method, args, obj) {
var _output, innerText;
function runPartial(self, method, args, obj, mode) {
var _output, _mode, innerText;
var stack = [];

@@ -211,7 +212,7 @@ var name = args[0];

if (partial == null) {
throw new Error("Partial " + name + " not found");
//throw new Error("Partial " + name + " not found");
}
if (error = tokenizer(partial.template, stack)) {
throw new Error(error);
//throw new Error(error);
}

@@ -221,11 +222,17 @@

// Save original output state
// Save original output state and mode
_output = output;
_mode = mode.get();
// Clear it for the inner text
// Clear output and modes for the inner text
output = "";
mode.clear();
// Parse the partial
innerText = render(self, partial.context, stack, _delimiters);
// Reset output and mode
output = _output;
mode.set(_mode);
mode.unset("skip");

@@ -285,3 +292,3 @@ return innerText;

if (error = tokenizer(innerText, stack)) {
throw new Error(error);
//throw new Error(error);
}

@@ -315,3 +322,3 @@

keys = Object.keys(obj);
keys = obj ? Object.keys(obj) : [];
if (keys.length) {

@@ -323,3 +330,3 @@ for (i=0, iLen=keys.length; i<iLen; i++) {

if (error = tokenizer(innerText, stack)) {
throw new Error(error);
//throw new Error(error);
}

@@ -408,3 +415,3 @@

if (mode.count("loop") > 1) {
if (mode.exists("loop")) {
innerText += capture;

@@ -435,3 +442,3 @@ }

if (mode.count("loop") > 1) {
if (mode.exists("loop")) {
innerText += capture;

@@ -497,3 +504,3 @@

if (args.length < 1) {
throw new Error("No arguments supplied for if statement");
//throw new Error("No arguments supplied for if statement");
}

@@ -549,3 +556,3 @@ else if (args.length === 1) {

if (args.length < 1) {
throw new Error("No arguments supplied for each statement");
//throw new Error("No arguments supplied for each statement");
}

@@ -574,2 +581,6 @@ // Iterating an array

else if (method === "endeach") {
if (mode.exists("skip")) {
break;
}
mode.unset("loop");

@@ -607,3 +618,3 @@ if (!mode.exists("loop")) {

obj = runPartial(self, method, args, obj);
obj = runPartial(self, method, args, obj, mode);
mode.set("partial");

@@ -728,3 +739,3 @@ mode.set("expr");

if (error = tokenizer(template, stack, grammar)) {
throw new Error(error);
//throw new Error(error);
}

@@ -731,0 +742,0 @@

{
"name": "combyne",
"description": "Templating that works *hopefully* the way you'd expect.",
"version": "0.1.0",
"version": "0.1.1",
"author": "Tim Branyen <tim@tabdeveloper.com> (http://twitter.com/tbranyen)",

@@ -6,0 +6,0 @@ "main": "./lib/index.js",

@@ -1,6 +0,4 @@

combyne: node implementation
============================
combyne.js: A template engine that *hopefully* works the way you'd expect.
==========================================================================
A template engine that *hopefully* works the way you'd expect.
Getting started

@@ -7,0 +5,0 @@ --------------

@@ -228,1 +228,19 @@ var combyne = require( '../' )

};
exports.eachLoopConditional = function( test ) {
test.expect(3);
// Conditional in each loop using no context
var tmpl = combyne('{%each demo%}{%if "lol" == "lol"%}test{%endif%}{%endeach%}', { demo: [ 1, 2, 3 ] });
test.equals( tmpl.render(), 'testtesttest', 'Conditional in each loop using no context' );
// Conditional in each loop using original context
var tmpl2 = combyne('{%each demo%}{%if test == "lol"%}{{val}}{%endif%}{%endeach%}', { test: 'lol', demo: [ 1, 2, 3 ] });
test.equals( tmpl2.render(), 'hi', 'Conditional in each loop using original context' );
// Conditional in each loop using loop context
var tmpl3 = combyne('{%each demo as key val%}{%if key == "lol"%}{{val}}{%endif%}{%endeach%}', { demo: { lol: 'hi', you: 'me?', what: 'test' } });
test.equals( tmpl3.render(), 'hi', 'Conditional in each loop using loop context' );
test.done();
};

@@ -26,3 +26,3 @@ var combyne = require( '../' )

exports.partials = function( test ) {
test.expect(2);
test.expect(4);

@@ -36,10 +36,20 @@ // Simple single replace with same key name

// Testing partials with filters
var tmpl = combyne('{{test}} {%partial test%}', { test: 'hello world' });
tmpl.partials.add('test', '{{name}}', {
// Simple single replace with same key name
var tmpl2 = combyne('{{test}} {%partial test%}', { test: 'hello world' });
tmpl2.partials.add('test', '{{name}}', {
name: 'lol'
});
test.equals( tmpl.render(), 'hello world lol', 'Simple single replace with same key name' );
test.equals( tmpl2.render(), 'hello world lol', 'Simple single replace with same key name' );
// Empty partial context
var tmpl3 = combyne('{{test}} {%partial test%}', { test: 'hello world' });
tmpl3.partials.add('test', 'lol', {});
test.equals( tmpl3.render(), 'hello world lol', 'Empty partial context' );
// Empty partial context with trailing template data
var tmpl4 = combyne('{{test}} {%partial test%} 123', { test: 'hello world' });
tmpl4.partials.add('test', 'lol', {});
test.equals( tmpl4.render(), 'hello world lol 123', 'Empty partial context with trailing template data' );
test.done();
};
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