Problem with curly brackets

For support and discussion related to templates, themes, and imagesets in phpBB 3.1.
Scam Warning
Ciao121
Registered User
Posts: 239
Joined: Wed Jan 28, 2004 1:08 pm

Problem with curly brackets

Post by Ciao121 »

On a template file I have to use:

Code: Select all

var xxxx = {};	
bute when I open the page, in the source code I can see:

Code: Select all

var xxxx = ;	
Curly brackets are stripped down.
I think this is because curly brackets are used for template variables.
Should I escape them in any way?

Thank you!
Apri il tuo forum gratuito in 1 minuto.
Ciao121
Registered User
Posts: 239
Joined: Wed Jan 28, 2004 1:08 pm

Re: Problem with curly brackets

Post by Ciao121 »

Found solution here:
viewtopic.php?f=46&t=1171155
Apri il tuo forum gratuito in 1 minuto.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Problem with curly brackets

Post by david63 »

Try

Code: Select all

var my_var ='{MY_VAR}';
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Naguissa
Registered User
Posts: 502
Joined: Thu Mar 02, 2017 6:55 am
Location: Barcelona
Name: Naguissa

Re: Problem with curly brackets

Post by Naguissa »

Old, but I spent HOURS with something similar for my phpbb 3.2 installation and this post and this other (locked) where top results in search engines.


Let's say you want to print:

Code: Select all

{HELLO}
Yo have to do following substitutions:

Code: Select all

{ ---> {{'{'}}
} ---> {{'}'}}
Final code:

Code: Select all

{{'{'}}HELLO{{'}'}}


Explanation: With "{{" you bypass simple phpbb template sintax and go straight twig syntax. {{'xxx'}} in twig means "print literal xxx" and that's what it does.

Probably you can also use:

Code: Select all

{{'{HELLO}'}}
But I stopped at 1st solution, I'm really tired.
nl2dav
Registered User
Posts: 105
Joined: Tue Jun 25, 2002 10:39 pm
Location: NOP, The Netherlands

Re: Problem with curly brackets

Post by nl2dav »

I like to thank you for sharing this information, saved me a lot of work / time!

Return to “[3.1.x] Styles Support & Discussion”