Looking for Escape Character in Templates

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
User avatar
Galaxy21
Registered User
Posts: 111
Joined: Mon Aug 13, 2007 12:03 am
Location: Dresden, Deutschland
Contact:

Looking for Escape Character in Templates

Post by Galaxy21 » Thu Sep 04, 2008 9:44 am

I'm trying to add some JavaScript into a template file. Part of the code is following statement:

Code: Select all

var icons = {};
Now I have the problem, that the template parser removes the {} (becuase it's used for variables) which of course causes a script error.
The question is, is there an escape character I can use to tell the template parser, this is not a variable? I tried \, but that wasn't it. ;)

As a work around my script now looks like this:

Code: Select all

var icons = {{}};
But is there a better way?

User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 50926
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: Looking for Escape Character in Templates

Post by stevemaury » Thu Sep 04, 2008 12:32 pm

For the left brace, try { and for the right one, #&125;
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)

User avatar
Galaxy21
Registered User
Posts: 111
Joined: Mon Aug 13, 2007 12:03 am
Location: Dresden, Deutschland
Contact:

Re: Looking for Escape Character in Templates

Post by Galaxy21 » Thu Sep 04, 2008 3:18 pm

This doesn't work, because then the source code of the site reads:

Code: Select all

var icons = {#&125;;
but it needs to be:

Code: Select all

var icons = {};
{ and #&125; would only work for text I wana display. But it's not a text problem. :roll:

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Looking for Escape Character in Templates

Post by Brf » Thu Sep 04, 2008 3:35 pm

What does

Code: Select all

var icons = {};
mean?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Looking for Escape Character in Templates

Post by Brf » Thu Sep 04, 2008 3:38 pm

OIC.... do this instead:

Code: Select all

var icons = new Object();

User avatar
Galaxy21
Registered User
Posts: 111
Joined: Mon Aug 13, 2007 12:03 am
Location: Dresden, Deutschland
Contact:

Re: Looking for Escape Character in Templates

Post by Galaxy21 » Thu Sep 04, 2008 4:05 pm

Code: Select all

var icons = {};
I use this to initialize an array for the icons. Basicly it contains the file names for the icons in use. A function gets the appropriate icon from that array later. So it's not an object.

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51890
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Looking for Escape Character in Templates

Post by Brf » Thu Sep 04, 2008 4:07 pm

Then use

Code: Select all

var icons = new Array();

User avatar
Galaxy21
Registered User
Posts: 111
Joined: Mon Aug 13, 2007 12:03 am
Location: Dresden, Deutschland
Contact:

Re: Looking for Escape Character in Templates

Post by Galaxy21 » Thu Sep 04, 2008 5:21 pm

Thank you. That seems to work.

Locked

Return to “[3.0.x] Support Forum”