1

I am attempting to load a temple and within that template is a partial(nested template). Shouldn't the partials constructor render the content partial? Is the logic done wrong? Similar question here but the implementation is different and no answer. The question appeared to die or was directed to somewhat similar question, but mine is also different in implementation.

base.mustache:

<body>  
{{>content}}
</body>

Mustache constructor:

if(!isset($this->mustache)){
            $options = array(
              'loader'=> new Mustache_Loader_FilesystemLoader('path/to/templates/'),
              'partials_loader' => new Mustache_Loader_FilesystemLoader('path/to/partials'),
              'partials' => array(
                  'content'=> $this->module->tplFile
              )
            );
            $this->mustache = new Mustache_Engine($options);
        }

Render template:

public function display()
    {
      $this->mustache->render('base.mustache');
    }
k.wig
  • 39
  • 1
  • 7

1 Answers1

0

First of all, you didn't even loaded the template.

Just edit your render template part like this :

public function display(){
  $this->mustache->loadTemplate('base')->render();
}

Why just 'base' not 'base.mustache', you might ask.

Well, Mustache default loading a .mustache file so if you using $this->mustache->loadTemplate('foo'), it will automatically load a foo.mustache file under the path you set for file loader.

For more information, you could check in Template Loading section from mustache.php's official wiki.

Btw, my English sucks, so hope you understand what I saying.