Problem with passing parameters to html templates

Hi John, Hi all,

Thanks for the support, I was on holiday so now the more extensive answer. In Short: We are fine. This is what we did:

  • We are using Version 2.2.7 Beta of Caspar CG (we learned the “beta” is somewhat relative)
  • This is our update() function:

function update(id, text)
{
var el = document.getElementById(id);
el.innerHTML = text.replace(new RegExp("\_",“g”), " ");
}

/*
Important finding: You cannot pass text with containing blanks to Caspar CG, even when it is quoted. (Maybe there’s a different way of masking blanks?)

We are passing the text now with underscores instead of blanks and the above RegExp will match all underscores and replace them with blanks.

*/

  • The call for update would be now:

CG 1-1 INVOKE 1 update(‘text1’,‘This_is_a_Text’)

/*
This will then change the innerHTML of Element with ID “text1” to the Text “This is a Text”
*/

Thanks again, ticket closed! :slight_smile:

You just need to quote the string correctly:
CG 1-1 INVOKE 1 “update(‘text1’,‘This is a text with spaces’)”
Depending on how you are sending the AMCP command you might need to escape the quotes: \"

Also since you are using INVOKE you should name the function something other than UPDATE since it’s also called automatically once the template is started (which will throw an error with your code).