How do I use { character in label text?

2
I want to use {foo} in a label text on a screen. However, if I do this, I get an error saying a brace should be followed by another brace or by a number. So how do I escape { in label text?
asked
3 answers
2

The Label widget allows you to use Braces, the Text widget doesn't.

answered
1

it's a bug (so file a ticket), was also in a version a couple of releases ago with the signs < or > on a button (fixed in the recent modeler versions)

for that I wrote a little hacky dirty javascipt replacement in a HTML snippet, the button has the class gt:

setTimeout(function()
{
$('.gt').each(function(){
    
var $this = $(this);
    
var t = $this.text();
$this.html(t.replace(/&lt;/g, '<').replace(/&gt;/g, '>') );
});
},50);

 

maybe this widget is even better to use so you can skip the timeout part above: https://appstore.home.mendix.com/link/app/43096/Incentro-Business-Acceleration/JavaScript-Snippet

answered
0

In some cases, you can escape a character by the exact same character. Two examples:

Example 1
If you want to use the isMatch function to check if , it requires the following syntax

isMatch('some_string','[your_regex]')

Now if you would want to check for a single quote in a string, you’ll need to escape that single quote with another single quote.

isMatch('some_string','['']')


Example 2

If you want to use braces in a label or caption, make sure that you escape the left brace with another left brace. The resulting in error already explains this (at least in Mendix 7).

Brace should be followed by a number of digits or another brace.

The right brace doesn’t need escaping.

answered