davidB / handlebars_misc_helpers

A collection of helpers for handlebars (rust) to manage string, json, yaml, toml, path, file, http request.

Home Page:https://crates.io/crates/handlebars_misc_helpers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow assign helper to be called multiple times

iliekturtles opened this issue · comments

The assign helper clones the ctx parameter, assigns the value, and sets the result to the render context. Calling assign multiple times leaves the render context only containing the last assignment call.

let mut ctx = ctx.clone();
match ctx.data_mut() {
serde_json::value::Value::Object(m) => m.insert(name.to_owned(), value),
_ => None,
};
rc.set_context(ctx);

  • Should the original context be changed before assigning to the render context? This would allow for multiple assignments.
  • Is this actually desired behavior and the fix should be updated documentation? e.g. if calling assign multiple times is desired, a new complex object that maintains past values should be created.

Issue opened based on feedback in SuperCuber/dotter#134.