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.3.6 to 0.3.7

2

bower.json
{
"name": "combyne",
"version": "0.3.6",
"version": "0.3.7",
"main": "dist/combyne.js",

@@ -5,0 +5,0 @@ "devDependencies": {

@@ -86,2 +86,6 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.combyne=e()}}(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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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(_dereq_,module,exports){

}
case 'RenderExpression': {
commands.push(this.compileRender(node));
break;
}
default: {

@@ -188,2 +192,22 @@ commands.push('\'' + escapeValue(node.value) + '\'');

};
Compiler.prototype.compileRender = function (node) {
return [
'(',
'partials[\'',
node.value.template.trim(),
'\'].registerPartial',
'(\'',
node.value.partial.trim(),
'\', { render: function(_data) {',
'data = _data || data;',
'return ',
this.process(node.nodes),
';',
'}, data: data}),',
'partials[\'',
node.value.template.trim(),
'\'].render(data)',
')'
].join('');
};
module.exports = Compiler;

@@ -214,2 +238,4 @@ },{"./shared/encode":4,"./shared/map":5,"./shared/register_filter":6,"./shared/register_partial":7,"./support/array/map":14,"./support/array/reduce":14,"./utils/create_object":10,"./utils/type":13}],2:[function(_dereq_,module,exports){

makeEntry('PARTIAL', 'partial'),
makeEntry('START_RENDER', 'render'),
makeEntry('END_RENDER', 'endrender'),
makeEntry('MAGIC', '.')

@@ -303,3 +329,3 @@ ];

};
Combyne.VERSION = '0.3.6';
Combyne.VERSION = '0.3.7';
module.exports = Combyne;

@@ -489,2 +515,37 @@ },{"./compiler":1,"./grammar":2,"./shared/register_filter":6,"./shared/register_partial":7,"./tokenizer":8,"./tree":9,"./utils/defaults":11,"./utils/type":13}],4:[function(_dereq_,module,exports){

};
Tree.prototype.constructRender = function (root) {
root.type = 'RenderExpression';
var value = {
template: '',
partial: ''
};
var side = 'template';
LOOP:
while (this.stack.length) {
var node = this.stack.shift();
switch (node.name) {
case 'END_EXPR': {
break LOOP;
}
case 'ASSIGN': {
side = 'partial';
break;
}
default: {
value[side] += node.capture[0];
}
}
}
value.template = value.template.trim();
value.partial = value.partial.trim();
root.value = value;
if (!root.value.template) {
throw new Error('Missing valid template name.');
}
if (!root.value.partial) {
throw new Error('Missing valid partial name.');
}
this.make(root, 'END_RENDER');
return root;
};
Tree.prototype.constructPartial = function (root) {

@@ -703,4 +764,7 @@ root.type = 'PartialExpression';

}
case 'START_RENDER': {
return this.constructRender(expressionRoot);
}
default: {
throw new Error('Invalid expression type.');
throw new Error('Invalid expression type: ' + type.name);
}

@@ -707,0 +771,0 @@ }

@@ -86,2 +86,6 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.combyne=e()}}(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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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(_dereq_,module,exports){

}
case 'RenderExpression': {
commands.push(this.compileRender(node));
break;
}
default: {

@@ -188,2 +192,22 @@ commands.push('\'' + escapeValue(node.value) + '\'');

};
Compiler.prototype.compileRender = function (node) {
return [
'(',
'partials[\'',
node.value.template.trim(),
'\'].registerPartial',
'(\'',
node.value.partial.trim(),
'\', { render: function(_data) {',
'data = _data || data;',
'return ',
this.process(node.nodes),
';',
'}, data: data}),',
'partials[\'',
node.value.template.trim(),
'\'].render(data)',
')'
].join('');
};
module.exports = Compiler;

@@ -214,2 +238,4 @@ },{"./shared/encode":4,"./shared/map":5,"./shared/register_filter":6,"./shared/register_partial":7,"./support/array/map":9,"./support/array/reduce":10,"./utils/create_object":15,"./utils/type":18}],2:[function(_dereq_,module,exports){

makeEntry('PARTIAL', 'partial'),
makeEntry('START_RENDER', 'render'),
makeEntry('END_RENDER', 'endrender'),
makeEntry('MAGIC', '.')

@@ -303,3 +329,3 @@ ];

};
Combyne.VERSION = '0.3.6';
Combyne.VERSION = '0.3.7';
module.exports = Combyne;

@@ -576,2 +602,37 @@ },{"./compiler":1,"./grammar":2,"./shared/register_filter":6,"./shared/register_partial":7,"./tokenizer":13,"./tree":14,"./utils/defaults":16,"./utils/type":18}],4:[function(_dereq_,module,exports){

};
Tree.prototype.constructRender = function (root) {
root.type = 'RenderExpression';
var value = {
template: '',
partial: ''
};
var side = 'template';
LOOP:
while (this.stack.length) {
var node = this.stack.shift();
switch (node.name) {
case 'END_EXPR': {
break LOOP;
}
case 'ASSIGN': {
side = 'partial';
break;
}
default: {
value[side] += node.capture[0];
}
}
}
value.template = value.template.trim();
value.partial = value.partial.trim();
root.value = value;
if (!root.value.template) {
throw new Error('Missing valid template name.');
}
if (!root.value.partial) {
throw new Error('Missing valid partial name.');
}
this.make(root, 'END_RENDER');
return root;
};
Tree.prototype.constructPartial = function (root) {

@@ -790,4 +851,7 @@ root.type = 'PartialExpression';

}
case 'START_RENDER': {
return this.constructRender(expressionRoot);
}
default: {
throw new Error('Invalid expression type.');
throw new Error('Invalid expression type: ' + type.name);
}

@@ -794,0 +858,0 @@ }

@@ -167,2 +167,7 @@ /**

case "RenderExpression": {
commands.push(this.compileRender(node));
break;
}
default: {

@@ -321,3 +326,25 @@ commands.push("'" + escapeValue(node.value) + "'");

/**
* Compiles a render into JavaScript.
*
* @memberOf module:compiler.Compiler
* @param {object} node - The partial node to compile.
* @return {string} The compiled JavaScript source string value.
*/
Compiler.prototype.compileRender = function(node) {
return [
"(",
// Register this template as the child partial of the parent.
"partials['", node.value.template.trim(), "'].registerPartial",
"('", node.value.partial.trim(), "', { render: function(_data) {",
"data = _data || data;",
"return ", this.process(node.nodes), ";",
"}, data: data}),",
// Invoke the parent template with the passed data.
"partials['", node.value.template.trim(), "'].render(data)",
")"
].join("");
};
module.exports = Compiler;
});

@@ -44,2 +44,4 @@ /**

makeEntry("PARTIAL", "partial"),
makeEntry("START_RENDER", "render"),
makeEntry("END_RENDER", "endrender"),
makeEntry("MAGIC", ".")

@@ -46,0 +48,0 @@ ];

@@ -139,5 +139,5 @@ /**

*/
Combyne.VERSION = "0.3.6";
Combyne.VERSION = "0.3.7";
module.exports = Combyne;
});

@@ -144,2 +144,64 @@ /**

/**
* Build a descriptor to describe an instance of a render.
*
* @memberOf module:tree.Tree
* @param {object} root - Current token in stack or tree node to process.
* @return {object} The root element decorated.
*/
Tree.prototype.constructRender = function(root) {
root.type = "RenderExpression";
// What to return to the compiler.
var value = {
template: "",
partial: ""
};
// Start filling the template first.
var side = "template";
LOOP:
while (this.stack.length) {
var node = this.stack.shift();
switch (node.name) {
case "END_EXPR": {
break LOOP;
}
case "ASSIGN": {
side = "partial";
break;
}
default: {
// Capture the template and partial values.
value[side] += node.capture[0];
}
}
}
// Trim the template and partial values.
value.template = value.template.trim();
value.partial = value.partial.trim();
// Assign this value.
root.value = value;
// If no template, this is an error.
if (!root.value.template) {
throw new Error("Missing valid template name.");
}
// If no partial, this is an error.
if (!root.value.partial) {
throw new Error("Missing valid partial name.");
}
this.make(root, "END_RENDER");
return root;
};
/**
* Build a descriptor to describe an instance of a partial.

@@ -493,4 +555,8 @@ *

case "START_RENDER": {
return this.constructRender(expressionRoot);
}
default: {
throw new Error("Invalid expression type.");
throw new Error("Invalid expression type: " + type.name);
}

@@ -497,0 +563,0 @@ }

{
"name": "combyne",
"description": "A template engine that works the way you expect.",
"version": "0.3.6",
"version": "0.3.7",
"author": "Tim Branyen (@tbranyen)",

@@ -9,3 +9,3 @@ "main": "dist/combyne.js",

"amdefine": "~0.1.0",
"browserify": "~4.1.5",
"browserify": "~4.1.6",
"deamdify": "~0.1.1",

@@ -15,9 +15,9 @@ "grunt": "~0.4.5",

"grunt-contrib-jshint": "~0.10.0",
"grunt-jscs-checker": "~0.4.1",
"grunt-karma": "~0.8.2",
"grunt-karma-coveralls": "~2.4.4",
"grunt-jscs-checker": "~0.4.4",
"grunt-karma": "~0.8.3",
"grunt-karma-coveralls": "~2.5.1",
"grunt-simple-mocha": "~0.4.0",
"jsdoc": "~3.3.0-alpha5",
"karma-coverage": "~0.2.1",
"karma-mocha": "~0.1.0",
"karma-coverage": "~0.2.4",
"karma-mocha": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.4",

@@ -30,2 +30,2 @@ "karma-sauce-launcher": "~0.2.8"

}
}
}
<img align="left" src="http://dl.dropboxusercontent.com/u/79007/combyne.png">
**Stable: 0.3.6**
**Stable: 0.3.7**
[![Build Status](https://travis-ci.org/tbranyen/combyne.png?branch=master)](https://travis-ci.org/tbranyen/combyne)
[![Coverage Status](https://coveralls.io/repos/tbranyen/combyne/badge.png?branch=master)](https://coveralls.io/r/tbranyen/combyne?branch=master)
[![Code Climahttps://codeclimate.com/github/tbranyen/combyne/badgeste](https://codeclimate.com/github/tbranyen/combyne.png)](https://codeclimate.com/github/tbranyen/combyne)

@@ -345,2 +346,47 @@ No dependencies. Can be loaded as a browser global, AMD module, and Node

#### Render and inject a partial. ####
When using a framework that handles rendering for you and you wish to inject
your template into a different template (maybe a layout) in a given region
you can express this through a render expression.
Illustrated below is a typical use case for this feature:
``` javascript
var template = "{%render layout as content%}<h1>{{header}}</h1>{%endrender%}";
var context = { header: "Home page" };
var page = combyne(template);
// Register the layout template into the page template.
page.registerPartial("layout", combyne("<body>{%partial content%}</body>"));
var output = page.render(context);
/// output == "<body><h1>Home page</h1></body>"
```
The context object you pass at the `page.render` line will be propagated to
the partial template. This means that you can optionally pass a nested object
structure like:
``` javascript
var context = {
header: "My site",
page: {
header: "Home page"
}
};
// Pass the page object to the page template, restricting what it has access
// to.
var layout = "<title>{{header}}</title><body>{%partial content page%}</body>";
// Register it in the partial.
page.registerPartial("layout", combyne(layout));
var output = page.render(context);
/// output == "<title>My site</title><body><h1>Home page</h1></body>"
```
## Unit tests. ##

@@ -347,0 +393,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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