Remove theme_option

This helper is no longer used.
This commit is contained in:
Eric Huss 2025-08-13 18:04:12 -07:00
parent 76c5b6967a
commit 9fce4ad74c
3 changed files with 0 additions and 41 deletions

View file

@ -271,8 +271,6 @@ impl HtmlHandlebars {
no_section_label: html_config.no_section_label,
}),
);
// TODO: remove theme_option in 0.5, it is not needed.
handlebars.register_helper("theme_option", Box::new(helpers::theme::theme_option));
}
fn emit_redirects(

View file

@ -1,3 +1,2 @@
pub(crate) mod resources;
pub(crate) mod theme;
pub(crate) mod toc;

View file

@ -1,38 +0,0 @@
use handlebars::{
Context, Handlebars, Helper, Output, RenderContext, RenderError, RenderErrorReason,
};
use log::trace;
pub(crate) fn theme_option(
h: &Helper<'_>,
_r: &Handlebars<'_>,
ctx: &Context,
rc: &mut RenderContext<'_, '_>,
out: &mut dyn Output,
) -> Result<(), RenderError> {
trace!("theme_option (handlebars helper)");
let param = h.param(0).and_then(|v| v.value().as_str()).ok_or_else(|| {
RenderErrorReason::ParamTypeMismatchForName(
"theme_option",
"0".to_owned(),
"string".to_owned(),
)
})?;
let default_theme = rc.evaluate(ctx, "@root/default_theme")?;
let default_theme_name = default_theme.as_json().as_str().ok_or_else(|| {
RenderErrorReason::ParamTypeMismatchForName(
"theme_option",
"default_theme".to_owned(),
"string".to_owned(),
)
})?;
out.write(param)?;
if param.to_lowercase() == default_theme_name.to_lowercase() {
out.write(" (default)")?;
}
Ok(())
}