Skip to content
This repository has been archived by the owner on Sep 1, 2020. It is now read-only.

Include files from string template #81

Open
zodinyac opened this issue Mar 11, 2018 · 0 comments
Open

Include files from string template #81

zodinyac opened this issue Mar 11, 2018 · 0 comments

Comments

@zodinyac
Copy link

The following code doesn't work:

$str   = new Dwoo\Template\Str('{include(file="test.tpl")}');
echo $tpl->get($str);

$str is Str object and doesn't have correct templateFactory.

When I do

$str   = new Dwoo\Template\Str('{include(file="file:test.tpl")}');
echo $tpl->get($str);

It works when I added to File::templateFactory the following code:

if ($parentTemplate === null) {
    $parentTemplate = $core->getTemplate();
}
if (!($parentTemplate instanceof self)) { // added
    $includePath = $core->getTemplateDir(); // added
} // added
if ($parentTemplate instanceof self) {

And removed:

$class = 'Dwoo\Template\File';
if ($parentTemplate) {
    $class = get_class($parentTemplate); // removed this line
}

How I can fix this correctly? I can not use file templates from string templates.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant