browserify-handlebars icon indicating copy to clipboard operation
browserify-handlebars copied to clipboard

Two handlebars instances created

Open AndiDog opened this issue 11 years ago • 3 comments

Originally posted this issue here.

In the attached minimal project (using grunt and browserify-handlebars), two instances of handlebars are created

  1. from 'node_modules\handlebars\Lib\index.js'
  2. from 'node_modules\handlebars\Dist\Cjs\handlebars.js'

I think the reason is the alias 'dist/cjs/handlebars', but not sure. Of course I want only one default instance on which I can register my helpers globally. How would I resolve this ambiguity?

https://www.dropbox.com/sh/spn8du2g5pn4xt7/sGZFWWDWRA

AndiDog avatar Feb 22 '14 12:02 AndiDog

Here is a gist with a slightly modified version of the above project so you don't have to download a 25MB zip.

https://gist.github.com/AsaAyers/9172448

git clone https://gist.github.com/9172448.git
cd 9172448
npm install
npm test

You'll see that it throws Missing helper: 'list' even though it's defined here in main.coffee.

AsaAyers avatar Feb 23 '14 15:02 AsaAyers

As a work around I did find that if I replace

hbs = require('handlebars')

with

hbs = require('handlebars/runtime').default

it will register and use the helper.

AsaAyers avatar Feb 23 '14 15:02 AsaAyers

As a work around I did find that if I replace

hbs = require('handlebars') with

hbs = require('handlebars/runtime').default it will register and use the helper.

Thanks for the workaround. This would be a helpful addition to the documentation for anyone who uses helpers.

geekytime avatar May 28 '14 01:05 geekytime