2

I'm using Mustache 2.7.0 and trying to play with Blocks pragma for the first time.

Basically, I call basic.mustache

{{< layout }}
{{$ title}}{{page.meta.name}}{{/ title}}
{{/ layout }}

calling the block layout.mustache

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <h1>{{$ title}}test{{/ title}}</h1>
    </body>
</html>

I see the value of page.meta.name appear on the page, but not the tags written in layout.mustache.
Anyone have an idea why?

PHP

$mustache = new Mustache_Engine(array(
    'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS],
    'loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates'),
    'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')
));

$tpl = $mustache->loadTemplate('basic');
echo $tpl->render( $this );
Simon Arnold
  • 15,849
  • 7
  • 67
  • 85

1 Answers1

5

It seems that partials_loader are not compatibles with Pragma blocks.

Removing this line:

'partials_loader' => new Mustache_Loader_FilesystemLoader('htdocs/templates/partials/')

Solved my problem.

Simon Arnold
  • 15,849
  • 7
  • 67
  • 85
  • 1
    I think you realized this in your other question, but the issue is that parent templates are still considered partials, so they're loaded via the partials loader instead of the normal template loader. Most of the time, you should just use one template loader (and one directory) for both :) – bobthecow Dec 13 '14 at 01:17
  • 1
    Thanks. Saved me time and effort. – Basil Musa May 28 '15 at 12:39