biotope / biotope-build

Biotope Build Framework
https://build.biotope.sh
MIT License
24 stars 10 forks source link

Handlebars static and dynamic helpers #4

Closed alxbenz closed 6 years ago

alxbenz commented 6 years ago

Use same handlebars helpers for static templating and dynamic templating.

Currently the "hb:static" task uses the helpers from /lib/hbs-helpers.js. For dynamic templating on runtime we use a different file /resources/js/handlebars.helper.js.

It would be better to inject the handlebars.helper.js into the hb:static task, in order to have only one place to define helpers.

Disscussion so far:

@timomayer Not sure if this is a good idea we should not mixup build framework and frontend Framework @alxbenz I think it would be good to at least have this opportunity: for example if one project uses some complex hbs template with custom helpers for runtime templating but also needs to have a static preview. @janrembold In my opinion the best way would be to extract our helpers into its own repository and include it anywhere we need it

SheepFromHeaven commented 6 years ago

@janrembold @timomayer can't we just define an array of paths to helper files in the projectConfig file? This would keep build framework and frontend framework separated, but still make it possible to infuse helpers to the static handlebars build process.

smohadjer commented 6 years ago

@timomayer @janrembold I have opened a pull request https://github.com/biotope/build-framework/pull/38/ that allows adding custom helpers in projectConfig.js. I am opposed to using the same helper file for both frontend and build templating as this can have unnecessary performance penalty if we have many helpers that are needed by build, but not by run-time environment.

smohadjer commented 6 years ago

The changes to projectConfig.js were reverted. Helpers in resources/js/handlebars.helper.js are now available in both build and frontend frameworks.

timomayer commented 6 years ago

@smohadjer i agree with what you said in your previouse comment about performance when we have bigger helper files. think we should use projectConfig so it is cobfigurable if it should be the same helpers or not.