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 0.1.5 to 1.0.0

msg.txt

23

index.js

@@ -6,5 +6,10 @@ /*jshint node: true*/

module.exports = function(file) {
if (!/\.hbs|\.handlebars/.test(file)) return through();
var extensions = {
hbs: 1,
handlebar: 1
};
function hbsfy(file) {
if (!extensions[file.split(".").pop()]) return through();
var buffer = "";

@@ -18,3 +23,4 @@

// Compile only with the runtime dependency.
var compiled = "var Handlebars = require('handlebars-runtime');\n";
var compiled = "// hbsfy compiled Handlebars template\n";
compiled += "var Handlebars = require('hbsfy/runtime');\n";
compiled += "module.exports = Handlebars.template(" + js.toString() + ");\n";

@@ -27,1 +33,12 @@ this.queue(compiled);

hbsfy.configure = function(opts) {
if (!opts || !opts.extensions) return hbsfy;
extensions = {};
opts.extensions.forEach(function(ext) {
extensions[ext] = 1;
});
return hbsfy;
};
module.exports = hbsfy;

13

package.json
{
"name": "hbsfy",
"version": "0.1.5",
"version": "1.0.0",
"description": "Handlebars precompiler plugin for Browserify v2",
"main": "index.js",
"scripts": {
"test": "node test/test.js"
"test": "sh test.sh"
},

@@ -24,12 +24,11 @@ "repository": {

"dependencies": {
"through": "~2.2.7",
"handlebars": "~1.0.12"
"through": "~2.2.7"
},
"peerDependencies": {
"handlebars-runtime": "~1.0.12"
"handlebars": "~1.0.12"
},
"devDependencies": {
"browserify": "~2.4.0",
"handlebars-runtime": "~1.0.12"
"browserify": "~2.35.1",
"concat-stream": "~1.1.0"
}
}

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

Compiles Handlebars templates to plain Javascript. The compiled templates
depend only on [handlebars-runtime][] so they are lightweight and fast!
Compiles Handlebars templates to plain Javascript. The compiled templates only
have one copy of the Handlebars runtime so they are lightweight and fast!

@@ -17,3 +17,3 @@ ## Usage

Handlebars runtime will be automatically installed as [peer dependency][].
Handlebars will be automatically installed as [peer dependency][].

@@ -26,2 +26,3 @@ Then use it as Browserify transform module with `-t`:

```javascript

@@ -38,2 +39,18 @@ var template = require("./template.hbs");

## Programmatic usage
When compiling using Javascript code custom extensions
can be set:
```javascript
var hbsfy = require("hbsfy").configure({
extensions: ["html"]
});
var browserify = require("browserify");
var b = browserify("./index.js");
b.transform(hbsfy);
b.bundle().pipe(fs.createWriteStream("./bundle.js");
```
### Helpers

@@ -45,3 +62,3 @@

```javascript
var Handlebars = require("handlebars-runtime");
var Handlebars = require("hbsfy/runtime");
Handlebars.registerHelper("upcase", function(s) {

@@ -63,2 +80,13 @@ return s.toUpperCase();

## Changelog
### 1.0.0
- Remove `handlebars-runtime` dependency and depend directly on
the `handlebars` module as a [peer dependency][].
- Runtime must be now required with `require("hbsfy/runtime")` instead of
`require("handlebars-runtime")`.
- Thanks to @kamicane for teaching me how to do this.
- Option to configure template extensions
## Browserify?

@@ -72,3 +100,2 @@

[Browserify v2]: https://github.com/substack/node-browserify
[handlebars-runtime]: https://npmjs.org/package/handlebars-runtime
[peer dependency]: http://blog.nodejs.org/2013/02/07/peer-dependencies/

@@ -6,4 +6,4 @@ /*jshint node: true*/

var hbsfy = require("../index");
var Handlebars = require("handlebars-runtime");
var hbsfy = require("hbsfy");
var Handlebars = require("hbsfy/runtime");

@@ -10,0 +10,0 @@ Handlebars.registerHelper("upcase", function(s) {

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