Skip to content

Commit 7aab04d

Browse files
committed
When NULL is passed as an icon name, display no icon instead of raising an error.
1 parent cd3e6a9 commit 7aab04d

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
- Add support for scatter and bubble plots in the chart component. See [the chart documentation](https://sql.ophir.dev/documentation.sql?component=chart#component).
55
- further improve debuggability with more precise error messages. In particular, it usd to be hard to debug errors in long migration scripts, because the line number and position was not displayed. This is now fixed.
66
- Add a new `top_image` attribute to the [card](https://sql.ophir.dev/documentation.sql?component=card#component) component to display an image at the top of the card. This makes it possible to create beautiful image galleries with SQLPage.
7+
- Updated dependencies, for bug fixes and performance improvements.
8+
- New icons (see https://tabler-icons.io/changelog)
9+
- When `NULL` is passed as an icon name, display no icon instead of raising an error.
710

811
## 0.12.0 (2023-10-04)
912

src/templates.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,13 @@ fn icon_img_helper<'reg, 'rc>(
169169
) -> handlebars::HelperResult {
170170
let null = handlebars::JsonValue::Null;
171171
let params = [0, 1].map(|i| helper.params().get(i).map_or(&null, PathAndJson::value));
172-
let err_fmt = || {
173-
RenderErrorReason::Other(format!(
174-
"{{icon_img str int}}: invalid parameters {params:?}"
175-
))
172+
let name = match params[0] {
173+
JsonValue::String(s) => s,
174+
other => {
175+
log::debug!("icon_img: {other:?} is not an icon name, not rendering anything");
176+
return Ok(());
177+
}
176178
};
177-
let name = params[0].as_str().ok_or_else(err_fmt)?;
178179
let size = params[1].as_u64().unwrap_or(24);
179180
write!(
180181
writer,

0 commit comments

Comments
 (0)