Parcel: 馃檵 Handlebars

Created on 13 Dec 2017  路  6Comments  路  Source: parcel-bundler/parcel

Will Parcel handle imported handlebars templates out-of-the-box?

Help Wanted Feature

Most helpful comment

Yeah - that is how it works in the webpack loader.

You import the handlebars file (e.g. import templ from '../templates/my_template.hbs'). This doesn't import the handlebars template - it compiles to a template function, and then you can use this right in your code, e.g. const html = templ({name: "Bob Smith"}).

All 6 comments

What file extension do handlebar template files use?

@davidnagli They are .hbs by convention, I have also seen .handlebars.

Curious how this would work. Is the intent to be able to import the "compiled" hbs template, which is then used in code with data?

Yeah - that is how it works in the webpack loader.

You import the handlebars file (e.g. import templ from '../templates/my_template.hbs'). This doesn't import the handlebars template - it compiles to a template function, and then you can use this right in your code, e.g. const html = templ({name: "Bob Smith"}).

I recently made a plugin to address the lack of support for handlebars templates. https://www.npmjs.com/package/parcel-plugin-handlebars

I would love to contribute to the parcel bundler itself, If the need arises to include built in support of handlebars in parcel.

@TheBlackBolt awesome! Feel free to add the plugin to https://github.com/parcel-bundler/awesome-parcel for others to discover.

Was this page helpful?
0 / 5 - 0 ratings