Problem with curly brackets

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

Problem with curly brackets

Post by Ciao121 » Fri Nov 06, 2015 2:40 pm

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 » Fri Nov 06, 2015 2:53 pm

Found solution here:
viewtopic.php?f=46&t=1171155
Apri il tuo forum gratuito in 1 minuto.

User avatar
david63
Jr. Extension Validator
Posts: 13187
Joined: Thu Dec 19, 2002 8:08 am
Location: Lancashire, UK
Name: David Wood
Contact:

Re: Problem with curly brackets

Post by david63 » Fri Nov 06, 2015 3:08 pm

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!
My CDB Contributions | How to install an extension
I will not be accepting translations for any of my extensions in Github - please post any translations in the appropriate topic.
No support requests via PM or email as they will be ignored

Naguissa
Registered User
Posts: 58
Joined: Thu Mar 02, 2017 6:55 am
Name: Naguissa
Contact:

Re: Problem with curly brackets

Post by Naguissa » Fri Mar 10, 2017 2:19 pm

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: 101
Joined: Tue Jun 25, 2002 10:39 pm
Location: NOP, The Netherlands
Contact:

Re: Problem with curly brackets

Post by nl2dav » Thu Oct 26, 2017 4:09 am

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

Post Reply

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

Who is online

Users browsing this forum: No registered users and 5 guests

cron