Socket
Socket
Sign inDemoInstall

odesza

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

odesza - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

48

index.js

@@ -0,1 +1,7 @@

/**
* Flexible template engine powered by ES6 template strings.
*
* @author Wells Johnston <wells@littlstar.com>
*/
'use strict'

@@ -7,7 +13,16 @@

var odesza = {};
module.exports = odesza;
odesza.render = (path, vars) => {
/**
* Renders a template with the given variables.
*
* @param {string} template The template to render.
* @param {object} vars An object of key-value pairs representing the
* variables to be used in the template.
* @return {string} The rendered template.
*/
odesza.render = (template, vars) => {
try {
let t = fs.readFileSync(path).toString();
return vm.runInNewContext('`' + t + '`', vars);
return vm.runInNewContext('`' + template + '`', vars);
} catch (e) {

@@ -18,6 +33,27 @@ throw new Error(e);

/**
* @param {string} path The path to the template file.
* @param {object} options Options passed in to render the template.
* @return {string} The rendered template.
*/
odesza.compile = (path, options) => {
try {
var template = fs.readFileSync(path).toString();
} catch (e) {
throw new Error(e);
}
return this.render(template, options);
};
/**
* Adds support for express.
*
* @param {string} path
* @param {object} options
* @param {function} fn
*/
odesza.__express = (path, options, fn) => {
return fn(this.render());
return fn(this.compile(path, options));
};
module.exports = odesza;

2

package.json
{
"name": "odesza",
"version": "0.0.1",
"version": "0.0.2",
"description": "Flexible templates powered by ES6 template strings.",

@@ -5,0 +5,0 @@ "main": "index.js",

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