public function testLexerTagParsing() { $provider = new \Webiny\Htpl\TemplateProviders\ArrayProvider(['test' => '<w-include file="someVar"/>']); $htpl = new \Webiny\Htpl\Htpl($provider); $htpl->assign('someVar', 'someTemplate.htpl'); $result = $htpl->build('test')->getSource(); $this->assertSame('<?php Webiny\\Htpl\\Functions\\WInclude::htpl(' . \Webiny\Htpl\Processor\OutputWrapper::getVar('someVar') . ', $this->getHtplInstance()) ?>', $result); }
<?php $loader = (require __DIR__ . '/../../../vendor/autoload.php'); $loader->add('Webiny\\Htpl\\', __DIR__ . '/../../../src/'); for ($i = 0; $i < 1000; $i++) { // display the template $provider = new \Webiny\Htpl\TemplateProviders\FilesystemProvider([__DIR__ . '/template']); $cache = new \Webiny\Htpl\Cache\FilesystemCache(__DIR__ . '/temp/compiled'); $htpl = new \Webiny\Htpl\Htpl($provider, $cache); $htpl->setForceCompile(false); // assign variables $htpl->assign('entries', include __DIR__ . '/../entries.php'); $htpl->fetch('template.htpl'); }
<?php $loader = (require __DIR__ . '/../../../vendor/autoload.php'); $loader->add('Webiny\\Htpl\\', __DIR__ . '/../../../src/'); //for($i=0;$i<1000; $i++){ // display the template $provider = new \Webiny\Htpl\TemplateProviders\FilesystemProvider([__DIR__ . '/template']); $cache = new \Webiny\Htpl\Cache\FilesystemCache(__DIR__ . '/temp/compiled'); $htpl = new \Webiny\Htpl\Htpl($provider, $cache); $htpl->setForceCompile(false); // assign variables $htpl->assign('arr', include __DIR__ . '/../entries.php'); $htpl->assign('var', 'John Snow'); $htpl->fetch('varTest2.htpl'); //}