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

razorleaf

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

razorleaf - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

74

cli.js

@@ -9,13 +9,18 @@ #!/usr/bin/env node

for(var i = 2; i < process.argv.length; i++) {
var file = process.argv[i];
function render(input, outputFile, directory, callback) {
var buffers = [];
fs.readFile(file, "utf8", function(error, content) {
if(error) {
console.error(error);
process.exit(1);
input.on("error", callback);
output.on("error", callback);
input.on("readable", function() {
var part = input.read();
if(part) {
buffers.push(part);
}
});
var directory = path.dirname(path.resolve(file));
var outputFile = path.join(directory, path.basename(file, ".leaf") + ".html");
input.on("end", function() {
var content = Buffer.concat(buffers).toString("utf8");

@@ -28,12 +33,4 @@ var template = razorleaf.compile(content, {

fs.writeFile(outputFile, template(), {
encoding: "utf8",
mode: 0x180
}, function(error) {
if(error) {
console.error(error);
process.exit(1);
}
console.log("Rendered %s as %s", file, outputFile);
output.write(template(), function() {
callback(null, output);
});

@@ -43,2 +40,43 @@ });

function renderedStdin(error) {
if(error) {
console.error(error);
process.exit(1);
}
}
function renderedFile(error, output) {
output.close();
if(error) {
console.error(error);
process.exit(1);
}
}
for(var i = 2; i < process.argv.length; i++) {
var file = process.argv[i];
var input;
var output;
var directory;
var callback;
if(file === "-") {
directory = process.cwd();
input = process.stdin;
output = process.stdout;
callback = renderedStdin;
} else {
directory = path.dirname(path.resolve(file));
input = fs.createReadStream(file);
var outputFile = path.join(directory, path.basename(file, ".leaf") + ".html");
output = fs.createWriteStream(outputFile, {mode: 0x180});
callback = renderedFile;
console.error("Rendering %s as %s", file, outputFile);
}
render(input, output, directory, callback);
}
// vim:ft=javascript

@@ -180,3 +180,3 @@ "use strict";

function compile(tree) {
function compile(tree, options) {
var context = {

@@ -192,4 +192,3 @@ content: new OutputBuffer(),

var compiled = new Function(
"__util, data",
var code =
context.scope.code +

@@ -199,4 +198,9 @@ "\n__output = '';\n" +

"\nreturn __output;"
);
var compiled = new Function("__util, data", code);
if(options.debug) {
console.log(code);
}
return function(data) {

@@ -203,0 +207,0 @@ return compiled(utilities, data);

{
"name": "razorleaf",
"version": "1.0.1",
"version": "1.1.0",
"main": "razorleaf.js",

@@ -23,3 +23,3 @@ "files": [

"type": "git",
"url": "git://github.com/campersander/razorleaf"
"url": "https://github.com/campersander/razorleaf"
},

@@ -26,0 +26,0 @@ "bugs": {

@@ -79,6 +79,7 @@ "use strict";

options = options || {};
tree = loadExtends(tree, [], options);
loadIncludes(tree, [], options);
return compiler.compile(tree);
return compiler.compile(tree, options);
}

@@ -85,0 +86,0 @@

@@ -44,3 +44,3 @@ [![Build Status](https://travis-ci.org/campersander/razorleaf.png)](https://travis-ci.org/campersander/razorleaf)

```html
--&gt;A string &lt;--
--&gt; A string &lt;--
A string containing "double-quotes"

@@ -47,0 +47,0 @@ ```

"use strict";
var amp = /&/g;
var quot = /"/g;
var lt = /</g;
var gt = />/g;
var utilities = {
escapeAttributeValue: function(value) {
return ("" + value).replace(/&/g, "&amp;")
.replace(/"/g, "&quot;");
return ("" + value).replace(amp, "&amp;")
.replace(quot, "&quot;");
},
escapeContent: function(content) {
return ("" + content).replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;");
return ("" + content).replace(amp, "&amp;")
.replace(lt, "&lt;")
.replace(gt, "&gt;");
}

@@ -13,0 +18,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