cancel
Showing results for 
Search instead for 
Did you mean: 

HTML Templating with Handlebars Conditionals

former_member189945
Contributor
0 Kudos

Hi all,

Is it somehow possible to use Handlebars Conditionals with SAPUI5 HTML Templating? My problem is that I would like to define a Block in view which would be shown only if a value in a JSONModel is true.

I cannot find any mention about Handlebars Block Helpers in the SAPUI5 documentation besides "#each" helper. I tried to use "#if" similarly but it doesn't work.

Here's a jsbin:

http://jsbin.com/puzelicopoye/1/edit

And here's a link to Handlebars documentation about Block helpers:

http://handlebarsjs.com/block_helpers.html

Regards,

Kimmo

Accepted Solutions (1)

Accepted Solutions (1)

jmoors
Active Contributor
0 Kudos

Hi Kimmo,

I think the handlebars template is still under construction, and only supports the rendering of each, looking in the comments of 1.22.4, it had a TODO comment next to with, if and and unless.

Many thanks,

Jason

  // TODO: implement support for "if", "unless", "with", ...

  // extended helpers:

  //   - each

  //   - with   (TODO)

  //   - if     (TODO)

  //   - unless (TODO)

 

  // custom helpers:

  //   - control: allows to declare a UI5 control

  //   - element

  //   - attribute

  //   - property

  //   - aggregation

former_member189945
Contributor
0 Kudos

Hi Jason,

Thanks for the info and for looking that up. So we just have to wait for updates to UI5.

Then, any idea of a scenario where templating would be useful as it is now? #each can be replaced with aggregation bindings, can't it.

Regards,

Kimmo

jmoors
Active Contributor
0 Kudos

Hi Kimmo,

You can use for creating controls etc, looks like it's the block helpers that are still to be implemented.

Many thanks,

Jason

Answers (0)