Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Smarty3 Compiler plugin not wrapping output in php tags

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
mosuin
Smarty n00b


Joined: 08 Jul 2011
Posts: 2

PostPosted: Fri Jul 08, 2011 10:19 pm    Post subject: Smarty3 Compiler plugin not wrapping output in php tags Reply with quote

Here is a sample compiler plugin I am trying.
Code:

function smarty_compiler_hello($contents, &$smarty)
{
    return "echo 'hello world';";
}


As per manual this plugin should generate below code in compiled template
Code:

<?php
echo 'hello world';
?>


But my output is generated without php tags. ie like
Code:

echo 'hello world';


I found that if I wrap return value with php tags in the plugin then it is working.
For example the below code is working fine.
Code:

return "<?php echo 'hello world'; ?>";


I am little confused.
Should I wrap compiler output in php tags myself or smarty will take care of it?
Any help will be appreciated.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sun Jul 10, 2011 12:04 am    Post subject: Reply with quote

It's a bug in Smarty3 documentation.
The php tags must be returned by the compiler plugins.
Back to top
View user's profile Send private message
mosuin
Smarty n00b


Joined: 08 Jul 2011
Posts: 2

PostPosted: Sun Jul 10, 2011 4:50 am    Post subject: Reply with quote

Thank you. I thought the same.

So this is the right code:
Code:

return "<?php echo 'hello world'; ?>";
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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