Closed taufik-nurrohman closed 8 years ago
I apologize for my very bad English, but I can not understand why replace a reference to the template file in the compiled template file. You can see a more detailed example of where it is running as?
Because $foo->display()
will behave like echo $str
and $foo->fetch()
is basically the same as $str
.
The original theme file using a plain PHP syntax, if I can get the cached path, then I can create an optional CMS feature where user can use plain PHP or use template engine for their themes without affecting the CMS core.
Yes it is possible to replace the generated markup from the output buffer but it is the same as overwriting previous included + rendered file, so using template engine will only increase the workload twice.
I may need to consider to add new hooks on my CMS to handle this.
.php
extension which contains plain PHP code.tpl
to make it possible to use the Fenom syntax:article.php
article.tpl
$o_path = 'path/to/article.php';
$n_path = preg_replace('#\.php$#', '.tpl', $o_path);
if(file_exists($n_path)) {
include $fenom->doGetCachedPathFromName($n_path, $vars);
} else {
include $o_path;
}
Something like that.
I have a different question, and where there will be a compilation of fenom template? to replace php on tpl you must first compile it. It seems to me that can not be done as you have described, and will have to make changes in your cms to provide the correct output templates.
And where there will be a compilation?
It should return the compiled version with .php
extension. If the compiled version is still not available, the compilation will occur before the compiled path is returned.
… will have to make changes in your CMS to provide the correct output templates.
I’m now thinking about it.
If that’s not possible, looks like this will only be a request to add a feature that allows us to load a template with include
.
Update: BTW how to use this part?
In the next version I will make a function that will return the path to the cache
Thanks.
In 2.11.0
$fenom->getCompileName($template_name);
I want to create plugin with this Template Engine but I don’t know how to get the cached file path of the template. I want to use it to replace the original file that should be included so that the orginal template flle can be replaced by Fenom template. Something like this:
For:
Thanks.