broken html`".into(),
+ config: &config,
+ external_formatter: Some(&|media_type, _text, _config| {
+ assert!(matches!(media_type, deno_ast::MediaType::Html));
+ Err(anyhow::anyhow!("Syntax error from external formatter"))
+ }),
+ });
+ assert!(result.is_err());
+ assert_eq!(result.unwrap_err().to_string(), "Error formatting tagged template literal at line 0: Syntax error from external formatter");
+ }
}
diff --git a/src/generation/context.rs b/src/generation/context.rs
index 728ea7e9..9a15b9d7 100644
--- a/src/generation/context.rs
+++ b/src/generation/context.rs
@@ -45,7 +45,11 @@ use crate::utils::Stack;
/// cases the templates will be left as they are.
///
/// Only templates with no interpolation are supported.
-pub type ExternalFormatter = dyn Fn(MediaType, String, &Configuration) -> Option
;
+pub type ExternalFormatter = dyn Fn(MediaType, String, &Configuration) -> anyhow::Result