sunng87 / handlebars-rust

Rust templating with Handlebars

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with dynamic template?

mojindri opened this issue · comments

in my project, i have a couple of templates that are registered at run time and on the other hand, in my main render, i simply render the, the issue is , the rendering working correctly, since i had an update from verion 3.5 to 4.3.

Js structure
modules { module: "my template name registred by register_partial" }

{{#each modules}} {{> (module) content df_style=true }} {{/each}}

(module): is actually a variable containing registeredd template name , i face error "helper not found" on handlebars version 4,
it would be great if u could help me with the issue,
regards,
moji

@mojindri sorry for late response. This behaviour is changed in 4.x to align with original javascript version.

The new way to do that is like what documented in javascript docs: https://handlebarsjs.com/guide/partials.html#dynamic-partials

{{> (lookup . "module") content df_style=true }}

hi @sunng87 ,
thanks for the info,
but one question after trying this code, i have noticed, inside of my modules, this pieace of code doesnt work as before:

<table role="presentation" cellpadding="0" cellspacing="0" border="0"> <tr> {{ to_title_case title }} </tr> </table>

it raises error, that "title" is not initialised or something like that, "title" is actually one child element of "content", it feels like "content" children elements hasn't been passed down to my partial template(like in handlebars 3.x version), i was also wondering if this is also correct behaviour,
ATM i can access "title" like this {{to_title_case content.title}},
thank you!.
moji

By the way in handlebars-rust you need to change my previous example to:

{{> (lookup this "module") content df_style=true }}

And the case that requires content.title here seems like a bug. I have created a testcase to reproduce it.

thanks again for the quick fix ,
will there be any new release in this month (including the fix for this issue)?

I still need to verify if #536 really fixes the issue and will create a patch release once it's confirmed.

The change should have landed on crates.io as 4.3.5