When to use double curly brackets {{ }}

Here's a quick guide on when to use double curly brackets ("double curlies") in your Retool apps.

{{}} Case Example
:white_check_mark: Referencing any Retool-specific values {{ query1.data }} or {{ text1.value }}
:white_check_mark: Writing JavaScript {{ checkbox1.value ? 'approved' : 'denied'}} in a Text component's value field
:white_check_mark: Inside Transformers const data1 = {{ query1.data }}
:no_entry_sign: Inside JS queries const data1 = query1.data
:no_entry_sign: Inside Workflow branch blocks startTrigger.data

Some notes:

  • If the snippet containing double curlies doesn't highlight green or red, don't use double curlies!

:white_check_mark: image
:white_check_mark: image
:no_entry_sign: image

  • In general, the space between the curlies and the text is optional.

    • {{query1.data}} is the same as {{ query1.data }}.
  • Triple curlies can occasionally cause problems, so a space might be helpful.

    • {{{'key':123}}} might cause errors. Try {{ {'key': 123} }} instead.
  • If you notice a value is being displayed as table1.data[0].email instead of the actual email value, that's an indicator you need double curlies.

  • In Workflows, branches don't accept dynamic variables but other blocks do:

Leave any thoughts or feedback below :arrow_down: :slight_smile: !

5 Likes

Hi, is this situation related to this post?

2 Likes

Yes, the variable Test isn't defined in Retool environment so the curly brackets don't know what it relates to. The default Transformer suggests you define your variables up front:

// Reference external variables with curly brackets or using JS variables
const name = {{ current_user.firstName || 'world' }}
return 'Hello ' + name

So for your example the recommended option would be:

let Test = 'text';
let inputValue = {{ textInput[0].value }};
return inputValue.includes(Test);
6 Likes

Great exampleβ€”thank you for adding that to this post @Skizhu and thank you for the solution @dcartlidge :raised_hands:

1 Like

What about in workflow response blocks? Assuming we need curly braces?

Also, could this thread include when double quotes are needed? I know they
definitely aren't needed in query blocks but what about workflow response blocks?

Hi @Marcelo_Fernando_Vigo,

Response blocks shouldn't need double curly brackets:

If you want to return a string in your response block, and you are not dynamically referencing a value, then you'd wrap your response in quotes (single or double).

For example, a dynamic string value doesn't need additional quotes around it:

If you hardcode any of the string, you'll need quotes around the hardcoded part:

Let us know if you have any specific examples we should expand on :slightly_smiling_face:

1 Like

so if i want to return json like this:

{
"message": "good",
"message_id": 10"
"provider": "mailchimp"
}

Then i would need to wrapp it in backtics and use ${variablename} to reference any dynamic variables?

{ "message": "good", "message_id": ${message_id}" "provider": "mailchimp" }

Hi @Marcelo_Fernando_Vigo,

You should be able to reference dynamic values without that formatting:

Happy to look at a screenshot if that isn't working