mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-19 15:21:23 +02:00
Special case Response()->response()
This commit is contained in:
@@ -27,6 +27,14 @@ impl PluginTemplateCallback {
|
|||||||
|
|
||||||
impl TemplateCallback for PluginTemplateCallback {
|
impl TemplateCallback for PluginTemplateCallback {
|
||||||
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String, String> {
|
async fn run(&self, fn_name: &str, args: HashMap<String, String>) -> Result<String, String> {
|
||||||
|
// The beta named the function `Response` but was changed in stable.
|
||||||
|
// Keep this here for a while because there's no easy way to migrate
|
||||||
|
let fn_name = if fn_name == "Response" {
|
||||||
|
"response"
|
||||||
|
} else {
|
||||||
|
fn_name
|
||||||
|
};
|
||||||
|
|
||||||
let plugin_manager = self.app_handle.state::<PluginManager>();
|
let plugin_manager = self.app_handle.state::<PluginManager>();
|
||||||
let function = plugin_manager
|
let function = plugin_manager
|
||||||
.get_template_functions()
|
.get_template_functions()
|
||||||
|
|||||||
@@ -81,9 +81,15 @@ function templateTags(
|
|||||||
|
|
||||||
// TODO: Search `node.tree` instead of using Regex here
|
// TODO: Search `node.tree` instead of using Regex here
|
||||||
const inner = rawTag.replace(/^\$\{\[\s*/, '').replace(/\s*]}$/, '');
|
const inner = rawTag.replace(/^\$\{\[\s*/, '').replace(/\s*]}$/, '');
|
||||||
const name = inner.match(/(\w+)[(]/)?.[1] ?? inner;
|
let name = inner.match(/(\w+)[(]/)?.[1] ?? inner;
|
||||||
let option = options.find((v) => v.name === name);
|
|
||||||
|
|
||||||
|
// The beta named the function `Response` but was changed in stable.
|
||||||
|
// Keep this here for a while because there's no easy way to migrate
|
||||||
|
if (name === 'Response') {
|
||||||
|
name = 'response';
|
||||||
|
}
|
||||||
|
|
||||||
|
let option = options.find((v) => v.name === name);
|
||||||
if (option == null) {
|
if (option == null) {
|
||||||
option = {
|
option = {
|
||||||
invalid: true,
|
invalid: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user