Closed ibabushkin closed 7 years ago
Empty strings should be handled as "false" as they are a falsy value (see https://github.com/janl/mustache.js/issues/186 for a rationale).
FYI, the code referenced above seems to be at line 278.
Does this commit https://github.com/ibabushkin/rust-mustache/commit/1bd7ebf9ecae6aad5f89f9016e9b315a1c2b8fc4 satisfy your requirements? If so, I'd open a pull-request.
Yes please, we'd like a pull request.
Given a template such as this one:
and using
as the data passed to the compiled template, I am receiving the following panic:
A code search in the repo yields the following lines in
src/template.rs
as the culprit:Now, the spec doesn't quite specify a clear behaviour on whether string values are to be interpreted as "thruthy", "falsey" or whether this decision is up to the host language's interpretation of this question. Now, in either case, either some filtering at template-compile-time should be done, or strings should be explicitly handled.
I can provide a fix for this (I suggest handling strings as
true
), but I'd like to know how the authors/maintainers see this issue.