Skip to content

Commit 4da05d6

Browse files
committed
Fix access to top-level variables
1 parent 667ba0b commit 4da05d6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/render.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::templates::SplitTemplate;
22
use crate::AppState;
33
use anyhow::Context as AnyhowContext;
44
use async_recursion::async_recursion;
5-
use handlebars::{Context, Handlebars, JsonValue, RenderError, Renderable};
5+
use handlebars::{Context, Handlebars, JsonValue, RenderError, Renderable, BlockContext};
66
use serde::Serialize;
77
use serde_json::{json, Value};
88
use std::borrow::Cow;
@@ -288,6 +288,7 @@ impl<'reg> SplitTemplateRenderer<'reg> {
288288
) -> Result<(), RenderError> {
289289
if let Some(local_vars) = self.local_vars.take() {
290290
let mut render_context = handlebars::RenderContext::new(None);
291+
render_context.push_block(BlockContext::new());
291292
let blk = render_context
292293
.block_mut()
293294
.expect("context created without block");
@@ -349,7 +350,7 @@ mod tests {
349350
rdr.render_item(&mut output, json!({"x": 1}))?;
350351
rdr.render_item(&mut output, json!({"x": 2}))?;
351352
rdr.render_end(&mut output)?;
352-
assert_eq!(output, b"Hello SQL ! (1 : SQL) (2 : SQL) Goodbye SQL");
353+
assert_eq!(String::from_utf8_lossy(&output), "Hello SQL ! (1 : SQL) (2 : SQL) Goodbye SQL");
353354
Ok(())
354355
}
355356
}

0 commit comments

Comments
 (0)