From d02c63dccf0d133d3108cdb62a2dfa3f49b58f6b Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sun, 7 Nov 2021 15:53:32 +0100 Subject: [PATCH] feat(render): add tip in logs when legacy form syntax throws error #856 --- espanso-render/src/renderer/mod.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/espanso-render/src/renderer/mod.rs b/espanso-render/src/renderer/mod.rs index 8fb2a17..4fd11c0 100644 --- a/espanso-render/src/renderer/mod.rs +++ b/espanso-render/src/renderer/mod.rs @@ -135,6 +135,29 @@ impl<'a> Renderer for DefaultRenderer<'a> { "unable to inject variables into params of variable '{}': {}", variable.name, err ); + + if variable.var_type == "form" { + if let Some(RendererError::MissingVariable(_)) = + err.downcast_ref::() + { + error!(""); + error!("TIP: This error might be happening because since version 2.1.0-alpha, Espanso changed"); + error!("the syntax to define form controls. Instead of `{{{{control}}}}` you need to use"); + error!("[[control]] (using square brackets instead of curly brackets)."); + error!(""); + error!("For example, you have a form defined like the following:"); + error!(" - trigger: test"); + error!(" form: |"); + error!(" Hi {{{{name}}}}!"); + error!(""); + error!("You'll need to replace it with:"); + error!(" - trigger: test"); + error!(" form: |"); + error!(" Hi [[name]]!"); + error!(""); + } + } + return RenderResult::Error(err); } }