Fix a bug w.r.t. quoting and escaping boolean values with filters.
This commit is contained in:
parent
bd7866e973
commit
71378ed37d
@ -6,3 +6,8 @@ Dust automatically applies the `|h` filter to html escape unless `|s` is applied
|
||||
Iterate over all filters
|
||||
If `|s` is not present append `|h`, otherwise, leave filters as-in
|
||||
During render, `|s` does nothing, so we can just remove it on the dust side to prevent confusion.
|
||||
|
||||
Quoting
|
||||
-------
|
||||
|
||||
Oddly enough, `boolean|j|js` gets no quotes (meaning `boolean|j` remains a boolean) but `boolean|h|js` does get quotes (meaning that `boolean|h` becomes a string)
|
||||
|
@ -189,6 +189,9 @@ fn apply_filter(
|
||||
(serde_json::Value::String(string), Filter::JavascriptStringEncode) => {
|
||||
Ok(serde_json::Value::String(javascript_escape(string)))
|
||||
}
|
||||
(serde_json::Value::Bool(boolean), Filter::JavascriptStringEncode) => {
|
||||
Ok(serde_json::Value::Bool(*boolean))
|
||||
}
|
||||
(_, Filter::JavascriptStringEncode) => Ok(serde_json::Value::String(javascript_escape(
|
||||
&json_value.render(&Vec::new())?,
|
||||
))),
|
||||
|
@ -525,6 +525,7 @@ mod tests {
|
||||
use crate::renderer::context_element::Renderable;
|
||||
use crate::renderer::context_element::Walkable;
|
||||
use crate::renderer::CompareContextElement;
|
||||
use std::cmp::Ordering;
|
||||
|
||||
impl ContextElement for String {}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user