Switching back to Handlebars (from jsrender) ?



  • Hello,

    As was advised by @jan_blaha I consider switching back to Handlebars. I am just discovering the jsreport product and Handlebars looks very annoying to work with. jsrender seemed more friendly. Maybe I did not understand the basics, this is why I am asking here. Here are the reasons of my initial switch from Handlbars to jsrender:

    1. jsrender lets you do the tests directly inside the report like so : {{if someValue >= 2}}print this{{else}}print that{{/if}}. It seems that Handlebars requires to write a function for every single test. Did I miss something?
    2. it seems that jsrender lets you declare "variables" that you can use throughout the templates (with {{* someVar = 2}} ). Does Handlebars provide such a feature?
    3. I like jsrender's itemVar feature that lets you define an alias rather than using the clumsy ../../../field. This is just comfort and readability so I can live without it.

    Thanks for you inputs.



  • I understand the concern and I used to prefer using jsrender as well.
    However, Handlebars is just much more popular so we had to target our focus primarily on that. The Handlebars can be more chatty and less natural, but in the end you will reach your goals without big troubles.

    Here are some answers to your questions, but you can typically find the answers quickly at StackOverflow or in the handlebars docs.

    jsrender lets you do the tests directly inside the report like so : {{if someValue >= 2}}print this{{else}}print that{{/if}}. It seems that Handlebars requires to write a function for every single test. Did I miss something?

    https://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional

    it seems that jsrender lets you declare "variables" that you can use throughout the
    templates (with {{* someVar = 2}} ). Does Handlebars provide such a feature?

    You can use with helper, perhaps
    https://handlebarsjs.com/guide/builtin-helpers.html#with
    https://playground.jsreport.net/w/anon/P4y_7rdV

    I like jsrender's itemVar feature that lets you define an alias rather than using the clumsy ../../../field. This is just comfort and readability so I can live without it.

    This can be done with bloc parameters
    https://handlebarsjs.com/guide/block-helpers.html#block-parameters


Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.