Repository navigation
Replies: 2 comments
|
hi @pdaoust, currently it's not possible to use function as data field directly in handlebars-rust. Because internally we transformed all data into serde_json's I will suggest you to filter |
0 replies
|
Hi, thanks for the response. I ended up creating a |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm working on someone else's code, and the context passed into one template (let's call it a
Bar) contains one propertyfooswhich is aVec<Foo>. EachFoohas a propertywidgetwhich is used to filter in some{{#each}}blocks but not others. It'd be no problem if the template were simply generating content like this:{{#each foos}}{{#if widget}}<p>{{name}}</p>{{/if}}{{/each}}, but in some cases it's used to create a comma-separated list:As you can see, if the second-to-last
foois awidget, but the last one is not, there'll be a trailing comma, which causes the generated file to be invalid (it's generating JS code).I'd like to avoid creating a new
foos_that_are_widgetsfield on the context, so I'm wondering if it's possible to either:foos_that_are_widgets()function in theimplforBarthat returns the filtered vecfoosduring or before{{#each}}All reactions