Socket
Socket
Sign inDemoInstall

render-cli

Package Overview
Dependencies
98
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.3

lib/render.js

4

lib/command.js

@@ -15,3 +15,3 @@ // Generated by CoffeeScript 1.8.0

program.version('0.2.0').usage('<template> [options]').option('-c --context <path>', 'Input files that serve as context to your template.').option('-g, --globals <path>', 'Data that will be added to each context set.').option('-d, --defaults <path>', 'Data that will be added to each context set. This is just an alias: globals and defaults are merged together.').option('-o, --output <path>', 'The path or path template.').option('-e, --engine <name>', 'The templating engine to use. If not specified, we guess from the extension.').option('-n, --namespaced', 'Namespace JSON input by its filename.').option('-N, --fully-namespaced', 'Namespace JSON input by its full path.').option('-n, --newer-than [key]', 'Only render a context set if the output file does not yet exist, or the context is newer. The modified time for the newest context file will be used in comparisons. Alternatively, for data that will be iterated through, the context file its modified time might not be the same as the modified time for the constituent sets of data. In this case, you may specify the key at which to find the context set its modified date.').option('-f, --fresh', 'Rerender everything. Negates --newer-than (if specified)').option('-m, --many [key]', 'Render a template once for each item.').option('-p, --many-pairs', 'Render a template once for each key-value pair.').option('-k, --key <name>', 'What name to give an array in the template context.').parse(process.argv);
program.version('0.2.0').usage('<template> [options]').option('-c --context <path>', 'Input files that serve as context to your template.').option('-g --globals <path>', 'Data that will be added to each context set.').option('-d --defaults <path>', 'Data that will be added to each context set. This is just an alias: globals and defaults are merged together.').option('-o --output <path>', 'The path or path template.').option('-e --engine <name>', 'The templating engine to use. If not specified, we guess from the extension.').option('-n --namespaced', 'Namespace JSON input by its filename.').option('-N --fully-namespaced', 'Namespace JSON input by its full path.').option('-n --newer-than [key]', 'Only render a context set if the output file does not yet exist, or the context is newer. The modified time for the newest context file will be used in comparisons. Alternatively, for data that will be iterated through, the context file its modified time might not be the same as the modified time for the constituent sets of data. In this case, you may specify the key at which to find the context set its modified date.').option('-f --force', 'Rerender everything. Negates --newer-than (if specified)').option('-F --fast', 'Does not perform certain uniqueness checks etc. ').option('-m --many [key]', 'Render a template once for each item.').option('-p --many-pairs', 'Render a template once for each key-value pair.').option('-k --key <name>', 'What name to give an array in the template context.').option('-v --verbose', 'Output the path to each file being rendered.').parse(process.argv);

@@ -26,3 +26,3 @@ context = program.context;

options = _.pick(program, 'engine', 'namespaced', 'fullyNamespaced', 'newerThan', 'fresh', 'key');
options = _.pick(program, 'engine', 'namespaced', 'fullyNamespaced', 'newerThan', 'force', 'fast', 'key', 'verbose');

@@ -29,0 +29,0 @@ _.extend(options, {

// Generated by CoffeeScript 1.8.0
(function() {
var async, fs, merge, parseData, parsePaths, readData, utils, yaml, _,
var async, fs, merge, parseData, parsePaths, readData, unwrap, utils, yaml, _,
__slice = [].slice;

@@ -18,2 +18,4 @@

unwrap = utils.string.unwrap;
parsePaths = function(paths, options) {

@@ -92,7 +94,7 @@ var extension, extensionlessFilename, filename, namespace, path, segments, _i, _len, _ref, _results;

default:
throw new Error("Can only merge data from objects or arrays. Instead got: " + source.constructor);
throw new Error(unwrap("Can only merge data from objects or arrays. Instead got: " + source.constructor));
}
}
if (source.data.constructor !== destination.constructor) {
throw new Error("Mixed data types. Expected: " + destination.constructor.name + ". Instead got: " + source.constructor.name + ".");
throw new Error(unwrap("Mixed data types. Expected: " + destination.constructor.name + ". Instead got: " + source.constructor.name + "."));
}

@@ -121,15 +123,2 @@ if (destination.constructor === Object && source.namespace) {

exports.clashes = function(list, facets) {
var groups, offenders;
if (list.length < 2) {
return [];
}
groups = _.groupBy(list, function(obj) {
return _.values(_.pick(obj, facets));
});
return offenders = _.keys(_.pick(groups, function(group, key) {
return group.length > 1;
}));
};
}).call(this);
// Generated by CoffeeScript 1.8.0
(function() {
var PathExp, async, context, render, unwrap, utils, _;
var PathExp, async, colors, context, describe, groupby, render, timing, unwrap, utils, _;

@@ -9,4 +9,8 @@ _ = require('underscore');

colors = require('colors');
PathExp = require('simple-path-expressions').PathExp;
groupby = require('groupby-cli');
context = require('./context');

@@ -20,4 +24,25 @@

timing = {};
describe = function(timing, operations) {
var counts, duration, rps;
counts = _.countBy(operations, _.identity);
_.defaults(counts, {
rendered: 0,
skipped: 0
});
rps = utils.round(counts.rendered / (utils.elapsed(timing.render, timing.stop)), 2);
duration = utils.elapsed(timing.start, timing.stop);
if (counts.rendered) {
console.log('');
}
console.log(unwrap("Processed " + (counts.rendered.toString().bold) + " pages. Skipped " + (counts.skipped.toString().bold) + " pages."));
if (counts.rendered) {
return console.log(unwrap("Rendered " + (rps.toString().bold) + " pages per second, took " + (duration.toString().bold) + " seconds in total."));
}
};
module.exports = function(layoutPattern, outputPattern, contextEnum, globalsEnum, options, callback) {
var contexts, globals, layoutTemplate, offenders, outputPlaceholders, outputTemplate, renderer, renderingOptions;
timing.start = new Date();
_.defaults(options, {

@@ -52,7 +77,7 @@ key: 'items'

}
if (options.many) {
offenders = context.clashes(contexts, outputPlaceholders);
if (options.many && !options.fast) {
offenders = groupby.clashes(contexts, outputPlaceholders);
if (offenders.length) {
offenders = offenders.join(', ');
throw new Error(unwrap("Found more than one dataset for " + offenders + ". Pick an output filename template that produces a unique filename for each dataset."));
throw new Error(unwrap("Found more than one context set for " + offenders + ". Pick an output filename template that produces a unique filename for each set of context."));
}

@@ -68,3 +93,3 @@ }

}
renderingOptions = _.pick(options, 'engine', 'key', 'newerThan', 'fresh');
renderingOptions = _.pick(options, 'engine', 'key', 'newerThan', 'force', 'verbose');
_.extend(renderingOptions, {

@@ -74,5 +99,12 @@ output: outputTemplate

renderer = _.partial(render, layoutTemplate, _, renderingOptions);
return async.each(contexts, renderer, callback);
timing.render = new Date();
return async.mapSeries(contexts, renderer, function(err, operations) {
timing.stop = new Date();
if (options.verbose) {
describe(timing, operations);
}
return callback(err);
});
};
}).call(this);
// Generated by CoffeeScript 1.8.0
(function() {
var _;
var _,
__slice = [].slice;
_ = require('underscore');
exports.round = function(number, decimals) {
var power;
if (decimals == null) {
decimals = 0;
}
power = Math.pow(10, decimals);
return (Math.round(number * power)) / power;
};
exports.elapsed = function(start, stop) {
var difference;
difference = (stop - start) / 1000;
return exports.round(difference, 2);
};
exports.next = function() {
var args, callback;
callback = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
return process.nextTick(function() {
return callback.apply(null, [null].concat(__slice.call(args)));
});
};
exports.passthrough = function() {
var args, callback, _i;
args = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];
return process.nextTick(function() {
return callback(null);
});
};
exports.isDirectory = function(path) {

@@ -8,0 +40,0 @@ return (path.slice(-1)) === '/';

{
"name": "render-cli",
"version": "0.2.0",
"version": "0.2.3",
"description": "Render HTML from Jade, Handlebars, Swig and most other kinds of templates on the command line. Uses the consolidate.js template engine consolidation library for all heavy lifting.",

@@ -8,3 +8,3 @@ "main": "lib/index.js",

"render": "bin/render"
},
},
"scripts": {

@@ -32,8 +32,6 @@ "test": "echo \"Error: no test specified\" && exit 1"

"async": "^0.9.0",
"atpl": ">=0.7.6",
"colors": "^0.6.2",
"commander": "^2.3.0",
"consolidate": "^0.10.0",
"mkdirp": "^0.5.0",
"simple-path-expressions": "^1.0.0-rc1",
"underscore": "^1.7.0",
"atpl": ">=0.7.6",
"dot": "1.0.1",

@@ -46,2 +44,3 @@ "dust": "0.3.0",

"ejs": "0.7.1",
"groupby-cli": "^0.1.1",
"haml-coffee": "1.4.0",

@@ -58,2 +57,3 @@ "hamljs": "0.6.1",

"lodash": "1.2.0",
"mkdirp": "^0.5.0",
"mote": "0.2.0",

@@ -64,5 +64,7 @@ "mustache": "0.4.0",

"ractive": "0.3.7",
"simple-path-expressions": "^1.0.0-rc1",
"swig": "0.12.0",
"templayed": ">=0.2.3",
"toffee": "0.0.52",
"underscore": "^1.7.0",
"walrus": "0.9.0",

@@ -69,0 +71,0 @@ "whiskers": "0.2.2"

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc