Re: [SMARTY] Newline being inserted after plugin

Monte Ohrt <[email protected]> Wed, 10 Oct 2007 09:03:35 -0500
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
A new line is created after the ?> because PHP eats the newline.

So, this (foo outputs 'FOO'):

TEST"{foo}"TEST

is compiled to:

TEST"<?php echo foo(array(), $this);?>
"TEST

(see the newline inserted)

And the final output:

TEST"FOO"TEST

(no newline)


Josh Trutwin wrote:
> I created a smarty function called {link_to_template} that creates a
> URL designed to go inside a <a href=""> - for example:
>
> <a href="{link_to_template param1=xyz}">Blah</a>
>
> This creates a cache php file with the following:
>
> <a href="<?php echo
> smarty_function_link_to_template(array('param1' =>
> 'xyz'), $this);?> 
>
> ">Blah</a>
>
> There is a single blank line after the ?> (not two in the code above,
> I inserted one for readability).  This was never a problem under
> php4 - but moving the same site to php5 I get an error now:
>
> Fatal error: Cannot use string offset as an array in ...
>
> I verified the actual return value in the plugin does NOT contain a
> newline so it seems smarty is putting it in there.
>
> Is there any way to prevent a plugin from automagically inserting a
> carriage return after the ?> or is there something else I did?
>
> Thanks,
>
> Josh
>
>   

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php