You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sandbox script: Support reading async variables without parameters (e.g. %from%) within script #329
In the following example we try to read the %identity% variable and do something within the script:
%{%(async()=>{letval=awaitidentity;switch(val){case'email1@acme.com':
return"<p>The parameter email1@acme.com was read from Clipboard.</p>";default:
return`<p>Other value retrieved from Clipboard: ${val}</p>`;}})()%}%
Expected behavior: identity should retrieve the same string that %identity% would. The problem here is that the function isn't fully executed. Instead it returns an empty function or throws "ERR: TypeError: can't convert val to string ". The workaround would be to add parentheses, like this:
(async()=>{letval=awaitidentity();})()
But this returns the string %identity% - because by design an empty parameter list was not allowed.
As an acceptable workaround I tried supplying an empty string as argument, like this:
(async()=>{letval=awaitidentity("");})()
Interestingly, this returns an empty string at the moment. Let's implement this to work so that it returns the variable value like this:
changed the title [-]Sandbox script: variables without parameters cannot be evaluated within script[/-][+]Sandbox script: Support reading variables without parameters (e.g. %from%) within script[/+]on Oct 26, 2024
While testing, I also encountered an interesting behavior of the %clipboard()% function: It will preferably return html as format, so if we copy an email address from composer in the editing area, it will return a string like:
changed the title [-]Sandbox script: Support reading variables without parameters (e.g. %from%) within script[/-][+]Sandbox script: Support reading variables without parameters (e.g. `%from%`) within script[/+]on Oct 31, 2024
changed the title [-]Sandbox script: Support reading variables without parameters (e.g. `%from%`) within script[/-][+]Sandbox script: Support reading async variables without parameters (e.g. `%from%`) within script[/+]on Oct 31, 2024
Activity
[-]Sandbox script: variables without parameters cannot be evaluated within script[/-][+]Sandbox script: Support reading variables without parameters (e.g. %from%) within script[/+]RealRaven2000 commentedon Oct 26, 2024
While testing, I also encountered an interesting behavior of the
%clipboard()%function: It will preferably return html as format, so if we copy an email address from composer in the editing area, it will return a string like:so we will need a way of dealing with this, maybe by forcing plain text through a parameter. See new issue #330
RealRaven2000 commentedon Oct 26, 2024
Preview version:
smartTemplate-fx-4.9pre82.zip
this one supports using empty parentheses to return data without passing parameters, in order to get the result string
%from%like this:To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)
#330 #326 #329
[-]Sandbox script: Support reading variables without parameters (e.g. %from%) within script[/-][+]Sandbox script: Support reading variables without parameters (e.g. `%from%`) within script[/+][-]Sandbox script: Support reading variables without parameters (e.g. `%from%`) within script[/-][+]Sandbox script: Support reading async variables without parameters (e.g. `%from%`) within script[/+]RealRaven2000 commentedon Nov 11, 2024
Implemented in 4.9 - published 11/11/2024