dlmanning / browserify-handlebars

browserify transform module for handlebars
20 stars 10 forks source link

Two handlebars instances created #1

Open AndiDog opened 10 years ago

AndiDog commented 10 years ago

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

AsaAyers commented 10 years ago

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 commented 10 years ago

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.

geekytime commented 10 years ago

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.