Skip to content

Commit 54366d7

Browse files
committed
no jinja string coercion
1 parent 5b03057 commit 54366d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/recipe/jinja.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ impl Jinja {
129129
if let Some(simple_expr) = strip_expression(template) {
130130
// render as expression so that we know the type of the result
131131
let expr = self.env.compile_expression(simple_expr)?;
132-
return Ok((expr.eval(self.context())?, true));
132+
let evaled = expr.eval(self.context())?;
133+
if evaled.as_str().is_some() {
134+
// Make sure that the string stays a string by returning can_coerce: false
135+
return Ok((evaled.to_str().unwrap().to_string().into(), false));
136+
} else {
137+
return Ok((expr.eval(self.context())?, true));
138+
}
133139
}
134140

135141
// Otherwise just render it as string

0 commit comments

Comments
 (0)