You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for this very nice project. I love the simple and low-dependency philosophy.
Somewhat not in that vein: what would you think about supporting iteration over maps/objects? Currently iteration is restricted to arrays. Following the standard syntax in other templating languages, it could look something like this:
{{ for key, value in guests }}
The key is {key} and the value is {value}
{{ endfor }}
I poked around the code to see what the implementation would be like, and I think it would be straightforward (I would do it):
We would add a new instruction similar to PushIterationContext. Perhaps PushObjectIterationContext(Path<'template>, &'template str, &'template str) where the enum payload is (path to the map, key variable name, value variable name).
In the compiler, the parse_for function would be changed to split the key name on ,, and then construct either a array iteration spec (no commas), an object iteration spec (1 comma) or an error (2 or more commas).
The new instruction would have to be implemented in template.rs. This would follow array iteration, probably with a new ContextElement.
The text was updated successfully, but these errors were encountered:
Thank you for this very nice project. I love the simple and low-dependency philosophy.
Somewhat not in that vein: what would you think about supporting iteration over maps/objects? Currently iteration is restricted to arrays. Following the standard syntax in other templating languages, it could look something like this:
I poked around the code to see what the implementation would be like, and I think it would be straightforward (I would do it):
We would add a new instruction similar to
PushIterationContext
. PerhapsPushObjectIterationContext(Path<'template>, &'template str, &'template str)
where the enum payload is (path to the map, key variable name, value variable name).In the compiler, the
parse_for
function would be changed to split the key name on,
, and then construct either a array iteration spec (no commas), an object iteration spec (1 comma) or an error (2 or more commas).The new instruction would have to be implemented in
template.rs
. This would follow array iteration, probably with a newContextElement
.The text was updated successfully, but these errors were encountered: