Open hakimihamdan88 opened 7 years ago
There's a virtual filesystem in liquid/liquid in packagist. This is the package you will install with composer.
Used like this:
class MyFileSystem extends Liquid\FileSystem\Virtual
{
public static function fromArray($array)
{
return new static(function ($path) use ($array) {
if (isset($array[$path])) {
return $array[$path];
}
return '';
});
}
}
And then:
$template = new Template();
$template->setFileSystem(MyFileSystem::fromArray(array(
'example' => "Hello, {{ name }}!",
)));
$template->parse("{% include 'example' %}");
echo $template->render(array("name" => "World"));
possible to render include tag from array? I don't want to load from a file