Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

variables that contain delmiters error
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Fri Jan 02, 2015 9:31 am    Post subject: variables that contain delmiters error Reply with quote

Code:
Uncaught --> Smarty Compiler: Syntax error in template "12aa61e0d15df83bc3bc15f310fb95969c6b6b54" on line 177 "BLABLA {<li" - Unexpected "<" <-- thrown


The problem is I use "$this->fetch('string: '.$code); as loop until there is no more variables. I do it because of includes another tpl files into main tpl and the variables in the included tpl files are not compiled.

So it working great. But when one of variable values have { or } delimeters, I got the same error like above.

I try to use {literal} or replace with {ldelim} and {rdelim}, but I get same errors, because when it found in included rpl file, it compile it more than one time.

How to solve it, I becoming crazy !! Sad

Thank you!
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Jan 02, 2015 8:08 pm    Post subject: Reply with quote

Simple said, you're doing it wrong.
Please read documentation regarding template inclusion.
This is a natively supported feature, and you do not need to do any loops - Smarty doing that for you.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Jan 02, 2015 8:14 pm    Post subject: Reply with quote

After the opening { delimiter Smarty expects a valid Smarty tag.
But Smarty does see '<' as next character so it's a syntax error.

I would need to see a couple of lines around line 177 to understand how your code should work
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sun Jan 04, 2015 5:21 pm    Post subject: Reply with quote

AnrDaemon wrote:
Simple said, you're doing it wrong.
Please read documentation regarding template inclusion.
This is a natively supported feature, and you do not need to do any loops - Smarty doing that for you.


Can you explain how Smarty does the loop and how to use it?


Last edited by maorbari on Sun Jan 04, 2015 5:28 pm; edited 2 times in total
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 04, 2015 5:23 pm    Post subject: Reply with quote

http://www.smarty.net/docs/en/language.function.include.tpl
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sun Jan 04, 2015 6:06 pm    Post subject: Reply with quote

AnrDaemon wrote:
http://www.smarty.net/docs/en/language.function.include.tpl


When I said i include templates, I used this {include}
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 04, 2015 7:29 pm    Post subject: Reply with quote

Then why you're doing this in a loop?...
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sun Jan 04, 2015 8:05 pm    Post subject: Reply with quote

AnrDaemon wrote:
Then why you're doing this in a loop?...

Because I build plugins that call functions and objects and doing actions and than return variables. the variables are not compile and apear as {$aaa} instead of the valud, so I call to $smart->fetch more time until there is no vars.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 04, 2015 9:23 pm    Post subject: Reply with quote

What?…
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Sun Jan 04, 2015 9:41 pm    Post subject: Reply with quote

AnrDaemon wrote:
What?…

I build plugins.
The plugins do actions and return value that contains vars.
Example it return the value:
Code:
<div class="top">{$var}</div>


The variable $var apear as string "{$var}" and not apear as value of $var.

Because of that, I call to $smarty->fetch as loop until all vars are showed as value and not as string.[/code]
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 04, 2015 11:27 pm    Post subject: Reply with quote

Read documentation already.
You're making so little sense, it breaking the bounds of sanity check.
If you want to write a block-level plugin, JUST DO IT.
Stop inventing wheels.
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Mon Jan 05, 2015 7:11 am    Post subject: Reply with quote

AnrDaemon wrote:
Read documentation already.
You're making so little sense, it breaking the bounds of sanity check.
If you want to write a block-level plugin, JUST DO IT.
Stop inventing wheels.


What I do wrong?
What the problem, I have read all documentation and still have same problem. Can't found my problem.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Jan 05, 2015 10:26 am    Post subject: Reply with quote

Do you expect documentation to contain descriptions of problems? Seriously?
Documentation tell you how to do things right. Not how to fix your wrongs.
Smarty is quite powerful. But that makes it not fool-proof. Which you've demonstrated rather clear.
If you're unable to find solution yourself, present an example of what you want to achieve, and we'll see how to better approach it from Smarty side.
In either case, running the same code through Smarty::fetch() again and again is NOT the right way to do anything period.
Back to top
View user's profile Send private message
maorbari
Smarty Rookie


Joined: 27 Dec 2014
Posts: 10

PostPosted: Mon Jan 05, 2015 2:38 pm    Post subject: Reply with quote

AnrDaemon wrote:
Do you expect documentation to contain descriptions of problems? Seriously?
Documentation tell you how to do things right. Not how to fix your wrongs.
Smarty is quite powerful. But that makes it not fool-proof. Which you've demonstrated rather clear.
If you're unable to find solution yourself, present an example of what you want to achieve, and we'll see how to better approach it from Smarty side.
In either case, running the same code through Smarty::fetch() again and again is NOT the right way to do anything period.


Thank you I success.
But now the problem is:
Value of variable $name is "{$first} {$last}".
so if I type inside template: {$name} it print it as "{$first} {$last}" instead of the values of the $first and $last..
How to solve it?
Back to top
View user's profile Send private message
Stricted
Smarty n00b


Joined: 27 Dec 2014
Posts: 3

PostPosted: Mon Jan 05, 2015 4:37 pm    Post subject: Reply with quote

you can use the eval plugin http://www.smarty.net/docs/en/language.function.eval.tpl

or write directly in the tamplate: {$first} {$last} instead of {$name}
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP