I have 3 template files:
main.tpl
main_header.tpl
main_footer.tpl
I need to include the last 2 templates inside the first one using Mustache.php
I can't find documentation about it.
How can I do?
The included templates are called "partials" in Mustache. The tag to include them looks like this:
{{> main_header }}
{{> main_footer }}
You will need to set up a template loader so that Mustache can automatically load them.
Since your file extension is .tpl, you should also let your template loader know.
The resulting code probably looks something like this:
<?php
$m = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader(
__DIR__.'/path/to/views',
array('extension' => '.tpl')
),
));
echo $m->render('main', $data);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With