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

hbsfy

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hbsfy - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

test/custom_compiler_subargs_test.js

31

index.js
/*jshint node: true*/
var through = require("through");
var Handlebars = require("handlebars");
var xtend = require("xtend");
var defaultPrecompiler = require("handlebars");
var defaultCompiler = "require('hbsfy/runtime')";
var defaultExtensions = {

@@ -13,3 +14,4 @@ hbs: true,

// Convert string or array of extensions to a object
// Convert string or array of extensions to an object
function toExtensionsOb(arr) {

@@ -36,9 +38,17 @@ var ob = {};

var extensions = defaultExtensions;
var compiler = defaultCompiler;
var precompiler = defaultPrecompiler;
if (opts && opts.e) {
extensions = toExtensionsOb(opts.e);
}
if (opts) {
if (opts.e || opts.extensions) {
extensions = toExtensionsOb(opts.e || opts.extensions);
}
if (opts && opts.extensions) {
extensions = toExtensionsOb(opts.extensions);
if (opts.p || opts.precompiler) {
precompiler = require(opts.p || opts.precompiler);
}
if (opts.c || opts.compiler) {
compiler = opts.c || opts.compiler;
}
}

@@ -54,11 +64,10 @@

function() {
var js = Handlebars.precompile(buffer);
var js = precompiler.precompile(buffer);
// Compile only with the runtime dependency.
var compiled = "// hbsfy compiled Handlebars template\n";
compiled += "var Handlebars = require('hbsfy/runtime');\n";
compiled += "module.exports = Handlebars.template(" + js.toString() + ");\n";
compiled += "var HandlebarsCompiler = " + compiler + ";\n";
compiled += "module.exports = HandlebarsCompiler.template(" + js.toString() + ");\n";
this.queue(compiled);
this.queue(null);
});
}

@@ -65,0 +74,0 @@

{
"name": "hbsfy",
"version": "2.0.0",
"version": "2.1.0",
"description": "Handlebars precompiler plugin for Browserify v2",

@@ -29,6 +29,7 @@ "main": "index.js",

"devDependencies": {
"browserify": "~4.2.3",
"concat-stream": "~1.4.1",
"handlebars": "~1.3.0",
"browserify": "~4.2.3"
"ember-template-compiler": "^1.6.1",
"handlebars": "~1.3.0"
}
}

@@ -43,2 +43,4 @@ [![Build Status](https://travis-ci.org/epeli/node-hbsfy.png?branch=master)](https://travis-ci.org/epeli/node-hbsfy)

### Custom Extension
You can use `--extensions` or `-e` subarg option to configure custom extensions

@@ -49,2 +51,12 @@ for the transform:

### Alternate Precompiler/Compiler
You can specify how the templates are precompiled by using `-p` or `--precompiler`, which
might also be used with the `-c` or `--compiler` option, like so:
browserify -t [ hbsfy -p ember-template-compiler -c Ember.Handlebars ] main.js > bundle.js
By default the precompiler is the [handlebars](https://www.npmjs.org/package/handlebars) node module
and the compiler is `"require('hbsfy/runtime')"`.
## Programmatic usage

@@ -92,2 +104,6 @@

### 2.1.0
- Subargs options for alternate precompilers and compilers [31](https://github.com/epeli/node-hbsfy/pull/31)
### 2.0.0

@@ -94,0 +110,0 @@

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