|
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 |
iriePub Smarty Regular
Joined: 16 Jun 2006 Posts: 53
|
Posted: Tue Aug 15, 2006 9:23 am Post subject: Either a Bug or a not wanted Feature!? |
|
|
Hi,
I'm using {strip} to keep my templates readable.
here an example code:
Code: |
<img
{{*** some comment ***}}
{{if $ppFixWidth !== false}}
width="{{$ppFixWidth}}"
{{/if}}
{{*** some comment ***}}
{{if $ppFixHeight !== false}}
height="{{$ppFixHeight}}"
{{/if}}
alt="prepic 4 {{$row.beschreibung}}"
src="{{$row.tooltip_pre_pic}}"
/>
|
In the end I want to get all in one line. SO I use {strip} like the following:
Code: |
{strip}
<img
{{*** some comment ***}}
{{if $ppFixWidth !== false}}
width="{{$ppFixWidth}}"
{{/if}}
{{*** some comment ***}}
{{if $ppFixHeight !== false}}
height="{{$ppFixHeight}}"
{{/if}}
alt="prepic 4 {{$row.beschreibung}}"
src="{{$row.tooltip_pre_pic}}"
/>
{/strip}
|
But then, I don't get something like this:
<img alt="..." src=".." />
but this:
<imgalt="prepic 4 ..."src="..."/>
I think this is a bug. There should be at least one Space betweedn the attributes ...
How to fix that? Or do I use this block in the wrong way?
Thanks!! |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Aug 15, 2006 9:56 am Post subject: Re: Either a Bug or a not wanted Feature!? |
|
|
iriePub wrote: | I think this is a bug. |
I think it's a feature. http://smarty.php.net/manual/en/language.function.strip.php says:
Quote: | Anything within {strip}{/strip} tags are stripped of the extra spaces or carriage returns at the beginnings and ends of the lines before they are displayed. |
|
|
Back to top |
|
iriePub Smarty Regular
Joined: 16 Jun 2006 Posts: 53
|
Posted: Tue Aug 15, 2006 11:38 am Post subject: |
|
|
Ok, then I misunderstood something, but somewhere I read something like
"any carriage returns, newlines, tabs and spaces are replaced by one space"
So do I have to create my own block-plugin? Something like
{strip2space}
?
Or is there a way to do, what I want?
Edit: Ok, I have it now like this, and it works:
Code: |
/**
* Strip Block
*
* Alle Newslines, Tabs, Wagenrückläuft und Leerzeichen werden innerhalb
* von {strip2space} und {/strip2space} durch 1 Leerzeichen ersetzt
*/
function smarty_block_strip2space($param, $content, &$smarty) {
return preg_replace('~\s+~i', ' ', $content);
}
$smarty->register_block('strip2space', 'smarty_block_strip2space', false);
// TEMPLATE:
{strip2space}
<img
src="..."
alt="..."
/>
{/strip2space}
|
|
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
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
|