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

Either a Bug or a not wanted Feature!?

 
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
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 9:23 am    Post subject: Either a Bug or a not wanted Feature!? Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Aug 15, 2006 9:56 am    Post subject: Re: Either a Bug or a not wanted Feature!? Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
iriePub
Smarty Regular


Joined: 16 Jun 2006
Posts: 53

PostPosted: Tue Aug 15, 2006 11:38 am    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Aug 15, 2006 12:13 pm    Post subject: Reply with quote

iriePub wrote:
Ok, then I misunderstood something, but somewhere I read something like

"any carriage returns, newlines, tabs and spaces are replaced by one space"


you read http://smarty.php.net/manual/en/language.modifier.strip.php
but you used http://smarty.php.net/manual/en/language.function.strip.php
which is something completely different.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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
Page 1 of 1

 
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