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

Include inline with string resource is not displaying output

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
Girish
Smarty Rookie


Joined: 05 Jan 2017
Posts: 5

PostPosted: Thu Jan 05, 2017 4:41 pm    Post subject: Include inline with string resource is not displaying output Reply with quote

I am trying to use include inline to parse the smarty string but it's not working as expected.

{$b = 'testing'}
{$a = '{$b}'}
{include file="string:{$a}" inline=true}

I can parse the smarty string in two way as stated below.
1. eval:
Code:

{eval var=$a}


2. include string:
Code:

{include file="string:{$a}"}


but this two methods either slow or creating unnecessary complied files for string so we were trying to use include inline but it's seems like it's not working with string resource.

We are getting below compiled code.

Code:


<?php if ($_valid && !is_callable('content_586e6f08b54a36_41684193')) {function content_586e6f08b54a36_41684193($_smarty_tpl) {?>
      <?php $_smarty_tpl->tpl_vars['b'] = new Smarty_variable('testing', null, 0);?>
      <?php $_smarty_tpl->tpl_vars['a'] = new Smarty_variable('{$b}', null, 0);?>
      <?php /*  Call merged included template "string:" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("string:".((string)$_smarty_tpl->tpl_vars['a']->value), $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '3643586e6f08b164d7-81126064');
content_586e6f08b4fb35_56859121($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack);
/*  End of included template "string:" */?><?php }} ?>

<?php /* Smarty version Smarty-3.1.21-dev, created on 2017-01-05 09:06:32
         compiled from "da39a3ee5e6b4b0d3255bfef95601890afd80709" */ ?>
<?php if ($_valid && !is_callable('content_586e6f08b4fb35_56859121')) {function content_586e6f08b4fb35_56859121($_smarty_tpl) {?><?php }} ?>



Seems like function content_586e6f08b4fb35_56859121 not echoing anything.

Please help us on this.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Thu Jan 05, 2017 10:17 pm    Post subject: Reply with quote

Is it a value for an attribute:
Code:
{include file="string:{$a}" inline=true}

or a simple flag:
Code:
{include file="string:{$a}" inline}

if that would make a difference.
Back to top
View user's profile Send private message
Girish
Smarty Rookie


Joined: 05 Jan 2017
Posts: 5

PostPosted: Fri Jan 06, 2017 5:12 am    Post subject: Reply with quote

No any difference in result.

include inline with tpl file is working as expected but not with the string.

Code:

{include file="../../Common/generic_templates/sort_table_content.tpl" inline}


Compile code is.
Code:

<?php if ($_valid && !is_callable('content_586e6f08b54a36_41684193')) {function content_586e6f08b54a36_41684193($_smarty_tpl) {?>
      <?php $_smarty_tpl->tpl_vars['b'] = new Smarty_variable('testing', null, 0);?>
      <?php $_smarty_tpl->tpl_vars['a'] = new Smarty_variable('{$b}', null, 0);?>
      <?php /*  Call merged included template "../../Common/generic_templates/sort_table_content.tpl" */
$_tpl_stack[] = $_smarty_tpl;
 $_smarty_tpl = $_smarty_tpl->setupInlineSubTemplate("../../Common/generic_templates/sort_table_content.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0, '3643586e6f08b164d7-81126064');
ob_start(); content_586f2606aa7bf0_05947425($_smarty_tpl);
$_smarty_tpl = array_pop($_tpl_stack);  $_smarty_tpl->tpl_vars["abcd"] = new Smarty_variable(ob_get_clean());
/*  End of included template "../../Common/generic_templates/sort_table_content.tpl" */?>

php }} ?>
<?php /* Smarty version Smarty-3.1.21-dev, created on 2017-01-05 22:07:18
         compiled from "C:\svn\PsCore\trunk\Interfaces\Templates\Common\generic_templates\sort_table_content.tpl" */ ?>
<?php if ($_valid && !is_callable('content_586f2606aa7bf0_05947425')) {function content_586f2606aa7bf0_05947425($_smarty_tpl) {?><?php echo $_smarty_tpl->tpl_vars['content']->value;?>
<?php }} ?>


You can see the difference in this function content_586f2606aa7bf0_05947425, it's now echoing the respective variable.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Sun Jan 08, 2017 8:16 pm    Post subject: Reply with quote

"inline" is a flag. You can't assign value to it, it'll be a syntax error.
http://www.smarty.net/docs/en/language.function.include.tpl
Back to top
View user's profile Send private message
Girish
Smarty Rookie


Joined: 05 Jan 2017
Posts: 5

PostPosted: Mon Jan 09, 2017 12:53 pm    Post subject: Reply with quote

We tried with both the ways but no good luck.

Will you please do let us know how can we achieve this.
Back to top
View user's profile Send private message
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 -> Smarty Development 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