|
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 |
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Mon Feb 01, 2010 11:53 am Post subject: Linebreaks problem |
|
|
Code: | function somefunction() { return 1; }
$smarty->register_function('somefunction', 'somefunction'); |
Code: | {somefunction}
{somefunction} |
Smarty output (smarty removes linebreak between two functions):
Expected output (with linebreaks):
Evidently, this problem is because of inaccurate use of php openning/closing tags. As I understand, the code above is compiled to something like this:
Code: | <php somefunction(); ?>
<php somefunction(); ?> |
If so, linebreak after php closing tag is removed by php.
This whitespace behaviour is real problem. What should I use with this code:
Code: | {somefunction}
{somefunction} |
if I want to preserve whitespace? |
|
Back to top |
|
ChrisFah Smarty Pro
Joined: 02 Nov 2009 Posts: 159 Location: Traun, Austria
|
Posted: Mon Feb 01, 2010 4:44 pm Post subject: |
|
|
What, if i need functions to stay side by side ? So a forced line function is not needed.
Why dont u use something like this:
Code: | function somefunction() { return 1.'<br />'; }
$smarty->register_function('somefunction', 'somefunction'); |
Lg, Chris |
|
Back to top |
|
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Tue Feb 02, 2010 6:01 am Post subject: |
|
|
Quote: | What, if i need functions to stay side by side ? So a forced line function is not needed. |
If I need functions to stay side by side, I'll either put them side by side or use {strip} tag.
In my opinion, it would be good if Smarty development team made a decision and made this decision documented:
1. either always preserve whitespaces as they are in template (personally, I prefer this option)
2. or remove whitespaces after all smarty closing tags (i.e. after '}')
I suspect that for now development team does not care about whitespaces. If it happens that smarty closing tag '}' is replaced with php closing tag '?>' during compilation, whitespace is removed (because such is the behaviour of php closing tag). If the above does not happen, whitespace is preserved. The problem is that template designers don't know what happens during compilation (and they should not even think about this). I think the best way is to document this behaviour and not to change it from version to version. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Feb 02, 2010 4:33 pm Post subject: |
|
|
This will get fixed, it's an inconsistency in the smarty 3 compiler atm. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Feb 02, 2010 8:11 pm Post subject: |
|
|
The fix for this problem is in the SVN now |
|
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
|