# How to print curly braces

**URL:** <https://forum.rasa.com/t/how-to-print-curly-braces/12043>\
**Category:** Rasa Open Source\
**Created:** [June 25, 2019, 1:44pm UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043 "2019-06-25T13:44:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christiaanben](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/christiaanben/32/1184_2.png) [@Christiaanben](https://forum.rasa.com/u/Christiaanben)\
**Post date:** [June 25, 2019, 1:44pm UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043/1 "2019-06-25T13:44:23Z")

</div>

Hi, Recently there has been a change to the text generation to use regex for placing variable values inside templates instead of string.format. How do you place “{” or “}” inside a template to do something like this:

```auto
utter_custom:
- text: '{{"variable":"{value}"}}'

```

should print

```auto
{"variable":"asdf"}

```

---

<div class="post-metadata">

**Author:** ![naoko](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/naoko/32/196_2.png) [@naoko](https://forum.rasa.com/u/naoko)\
**Post date:** [June 26, 2019, 12:20am UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043/2 "2019-06-26T00:20:39Z")

</div>

It does not work as it is. Looks like a patch is needed somewhere around

> <https://github.com/RasaHQ/rasa/blob/master/rasa/core/nlg/template.py#L114>

I briefly tested out and adding open curly braces to blacklist character should do it.

```
>>> text = re.sub(r'{([^\n,{]+?)}', r'{0[\1]}', '{{"variable":"{value}"}}')
>>> text
'{{"variable":"{0[value]}"}}'
>>> text.format({"value": "new value"})
'{"variable":"new value"}'

```

I can find time this weekend to patch but if you need earlier, plz try the code above and see.

---

<div class="post-metadata">

**Author:** ![Christiaanben](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/christiaanben/32/1184_2.png) [@Christiaanben](https://forum.rasa.com/u/Christiaanben)\
**Post date:** [July 1, 2019, 2:17pm UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043/3 "2019-07-01T14:17:13Z")

</div>

No rush, I created a variable in my actions file and sent the variable through so long.

```auto
body = "{curly braces}"
dispatcher.utter_template('template_name', tracker, **{'body': body})

```

---

<div class="post-metadata">

**Author:** ![naoko](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/naoko/32/196_2.png) [@naoko](https://forum.rasa.com/u/naoko)\
**Post date:** [July 6, 2019, 11:22pm UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043/4 "2019-07-06T23:22:35Z")

</div>

FYI - [Fixed regex to find slot by black listing curly braces within curly b… by naoko · Pull Request #3951 · RasaHQ/rasa · GitHub](https://github.com/RasaHQ/rasa/pull/3951)

---

<div class="post-metadata">

**Author:** ![erohmensing](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/erohmensing/32/1789_2.png) [@erohmensing](https://forum.rasa.com/u/erohmensing)\
**Post date:** [July 7, 2019, 7:27pm UTC](https://forum.rasa.com/t/how-to-print-curly-braces/12043/5 "2019-07-07T19:27:25Z")

</div>

@naoko thanks for PRing your fix!
