CasparCG Client Template - If data keyword is empty

Hello there! I’m trying to get something for my html template but I’m a noob in CCG and JS. What I want to do is if the text/data filled in the template through the client is empty, or there’s no text/data attached to that keyword, I want to hide the whole element.

I tried with something like:

if (data[‘keyword’] == “”) {

But I can’t get it working. It works if I type some kind of text like “example” for that keyword, but it’s not working if there’s no data. Idk if I’m explaining myself tho.

Thank you in advance!

Do it the other way around: Hide the block on initialization and show it, when text comes in.

If you don’t send the data, it will be undefined instead of an empty string. In JavaScript you can check for “falsy” values (like undefined or the empty string) using the following code:

if (!data['keyword']) {