Binding variables with spaces in their names

Hi all,

I’m just stuck for a very long time with this issue. I have an api GET on server-side. The api returns key-value pairs where some of the keys (variables) have spaces, like this.

image
On client-side,

  • when I bind a variable that has no space in its name, the value is showing up correctly, like this.

image image

  • but, when I bind a variable that has a space in its name, the value is not showing up, instead the variable name is getting displayed! Ideally the value 96175 must be displayed as Order ID.

image image
I notice that wappler encloses such variables within single quotes & square brackets.

I tried renaming the variables on server-side in the schema. But, when I try binding the renamed variable, no value but this time, not showing the variable name also!

image image image image

Is this a bug, may be? Any help will be greatly appreciated! Thanks!

(1)Please first check the network tab in the debugger.
What do you see there as value for the variable with the space.
(2)Dont know if this will work just try to convert the variable into a number with the formatter

Thanks mate. I did check the network tab on my browser, definitely has a value. I can’t just convert it to number, as there are other similar variables (with their names having spaces) that has text values (that has to be printed as string).

image

So is the problem you are seeing in Wappler only, or {{['Order ID']}} shows the value in the browser?

No values on both wappler as well as browser.

Ok then, please try changing this to:
{{Order ID}} - is it fine then?

Didn’t work, no values on both wappler & browser.

image

image

Ok, i see.
Maybe @patrick can check this and advise.

1 Like

Spaces are not allowed in identifiers, so {{Order ID}} will give an parse error.

Using brackets like in {{['Order ID']}} will result in an array with Order ID as a string value. When using it on the page it will convert the array to string resulting you seeing Order ID on the page.

You can use brackets, but you need to know the parent component. When in a repeater you could probably use {{$value['Order ID']}}.

1 Like

Just enter this on your page:

2 Likes

Okay, that worked, thanks Teodor!

Would be great if wappler can add the $value while binding such variables with spaces within a repeat region.

Meanwhile, I can progress, already spent a lot of hours on this. Thanks again for the quick resolution!

1 Like