|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Gene.Parmesan Smarty n00b
Joined: 01 Jun 2011 Posts: 2
|
Posted: Wed Jun 01, 2011 10:43 am Post subject: Identical left and right delimiters |
|
|
I'm aware of the change in whitespace around delimiters in order to allow easier compatibility with JavaScript. However, in our case we used identical left and right delimiters (`) instead of the default '{' and '}'. This had always worked fine in Smarty 2, but upgrading to Smarty 3 generates an error.
The error is on the next line after an include:
Code: |
`include file="header.tpl" title=""`
<div id="content">
|
It implies that the right delimiter was not recognized as such, even though there is no trailing space after the right delimiter:
Quote: | Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "smarty/templates/index.tpl" on line 2 "<div id="content">" - Unexpected "` ", expected one of: "`" , " "' in C:\PHP\includes\sysplugins\smarty_internal_templatecompilerbase.php:431 |
Turning off auto_literal does not solve the problem. I suspect that the real issue is that identical left and right delimiters are not allowed, but I haven't seen any confirmation of this in the documentation.
It would appear that we're going to need to update all of our templates in order to migrate from Smarty 2 to Smarty 3 - anyone know of any workarounds or settings that would avoid this?[/code] |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jun 01, 2011 1:35 pm Post subject: |
|
|
Yes, the left and right delimiters must be different.
There is no way around it as Smarty3 does allow nested Smarty tags.
Also you should not use for same reasion backticks as delimiter as they have special meaning inside double quoted strings .
It's also a surprise to me that it did work in Smarty2.
Last edited by U.Tews on Wed Jun 01, 2011 1:37 pm; edited 1 time in total |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Jun 01, 2011 1:36 pm Post subject: |
|
|
oh, those are nasty delimiters, the "`" is a special character for Smarty inside quotes. Making both delimiters the same character may also be causing problems, but Uwe may respond with a better explanation.
For a quick fix, you could make a prefilter that converts your "`" delimiters to { and } just before compile time, so you don't have to change all your templates. FWIW, I would advise to change the delims and fix the templates with a search/replace. |
|
Back to top |
|
Gene.Parmesan Smarty n00b
Joined: 01 Jun 2011 Posts: 2
|
Posted: Wed Jun 01, 2011 2:15 pm Post subject: |
|
|
Fair enough. Might be good to mention in the docs that the delimiters must be different. Indeed identical delimiters mean that the templates cannot be updated with a simple search and replace, so a warning to all you out there who are tempted by the relative simplicity of identical delimiters, a la quotes or Perl regular expressions |
|
Back to top |
|
|
|
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
|