require-handlebars-plugin icon indicating copy to clipboard operation
require-handlebars-plugin copied to clipboard

Handlebars is tightly coupled

Open jscharett opened this issue 9 years ago • 2 comments

Looking at the doc, it states that you can use 'handlebarsPath' to specify the path to a different version of handlebars. However, looking at the hbs plugin, it requires 'hbs/handlebars'. It only seems to use the handlebarsPath when compiling the templates. In order for me to truly use a different version of handlebars, I need to set of a path in my require.config to point to the new version. Would be nice if the plugin could handle this for me in some fashion, so I don't need to specify 2 paths to handlebars in my config.

jscharett avatar Aug 16 '16 18:08 jscharett

Currently all dependencies are required immediately in the main define function of the hbs module. The plugin configuration is not accessible there yet. That's why the config.hbs.handlebarsPath setting, which gets applied during the build later in the module, affects only the compile phase.

Workarounds:

  1. Define alias for "hbs/handlebars" pointing to your own module path by require.config().
  2. Replace "hbs/handlebars" in this module by your own module path.
  3. Rewrite this module, so that it requires dependencies when the load method of the plugin gets called. You will have access to config.hbs.handlebarsPath then.

prantlf avatar Mar 05 '17 14:03 prantlf

completely new to this package and trying to upgrade the existing legacy code with below config,

require.config({ baseUrl: "./js", paths: { hbs: 'libraries/hbs/hbs', ...... }, hbs: { // optional helpers: true, // default: true i18n: false, // default: false templateExtension: 'tmpl', // default: 'hbs' partialsUrl: '', // default: '' },shim: { mxG: { exports: 'mxGraph', deps: ['mxGConfig', 'override'] }, jqueryactual: { exports: 'jqueryactual', deps: ['jquery-external'] }, uniform: { deps: ['jquery-external'] }, datatables: { deps: ['jquery-external'] }, toolbarRenderer: { deps: ['uniform'] }, menuManager: { deps: ['menu', 'menuItem'] }, renderManager: { deps: ['promise', 'canvasToBlob'] }, html2canvas: { exports: 'html2canvas' }, graphRenderer: { deps: ['jqueryactual'] }, canvg: { exports: 'canvg' }, filesaver: { exports: 'saveAs' }, handlebars: { exports: 'Handlebars' } }

and I need to upgrade the current hbs/hbs/handlebars.js -> v1.3.0 to v4.7.6

no luck with this approach, need your help for the same

Thanks in advance

neetusn avatar Jan 17 '21 15:01 neetusn