Mustache templates for the ProcessWire TemplateEngineFactory
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mustache
LICENCE.txt
README.md
TemplateEngineMustache.module

README.md

TemplateEngineMustache

ProcessWire module adding Mustache templates to the TemplateEngineFactory.

Installation

Install the module just like any other ProcessWire module. Check out the following guide: http://modules.processwire.com/install-uninstall/

This module requires TemplateEngineFactory: https://github.com/wanze/TemplateEngineFactory

After installing, don't forget to enable Mustache as engine in the TemplateEngineFactory module's settings.

Configuration (over TemplateEngineProcesswire Module Configuration)

  • Path to templates Path to folder where you want to store your Smarty template files.
  • Template files suffix The suffix of the template files, default is mustache.

Setting Helpers

$view->setHelpers([
  'myHelperFunction' => function($text) {
    return trim($text);
  }
]);

Examples

First expose data (in this case all story pages) to the mustache view being rendered next.

// In file: /site/templates/stories.php

$stories = $pages->find('template=blogstory');
$view->set('stories', $stories);

Then use the passed in data (story pages) in your mustache template file.

<!-- In file: /site/templates/views/stories.mustache -->

<h1>Stories</h1>
<ul>
{{#stories}}
  <li>
    <a href="{{url}}">
      {{title}}
    </a>
  </li>
{{/stories}}
</ul>