View previous topic :: View next topic |
Author |
Message |
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Fri Jan 02, 2015 9:31 am Post subject: variables that contain delmiters error |
|
|
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 !!
Thank you! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jan 02, 2015 8:08 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Jan 02, 2015 8:14 pm Post subject: |
|
|
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 |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sun Jan 04, 2015 5:21 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sun Jan 04, 2015 6:06 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jan 04, 2015 7:29 pm Post subject: |
|
|
Then why you're doing this in a loop?... |
|
Back to top |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sun Jan 04, 2015 8:05 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jan 04, 2015 9:23 pm Post subject: |
|
|
What?… |
|
Back to top |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Sun Jan 04, 2015 9:41 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sun Jan 04, 2015 11:27 pm Post subject: |
|
|
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 |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Mon Jan 05, 2015 7:11 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Jan 05, 2015 10:26 am Post subject: |
|
|
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 |
|
maorbari Smarty Rookie
Joined: 27 Dec 2014 Posts: 10
|
Posted: Mon Jan 05, 2015 2:38 pm Post subject: |
|
|
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 |
|
Stricted Smarty n00b
Joined: 27 Dec 2014 Posts: 3
|
|
Back to top |
|
|