Search the Community
Showing results for tags 'mustache'.
-
Hi, I’m trying to implement mustache.php into processwire. https://github.com/bobthecow/mustache.php What I did so far and what worked with one problem is: put the “Mustache” Folder in site/template make a _init_mustache.php <?php // include Mustache require __DIR__ . '/Mustache/Autoloader.php'; Mustache_Autoloader::register(); //start the mustache engine $mustache = new Mustache_Engine(array( 'template_class_prefix' => '__MyTemplates_', 'cache' => dirname(__FILE__).'/tmp/cache/mustache', 'cache_file_mode' => 0666, // Please, configure your umask instead of doing this :) 'cache_lambda_templates' => true, 'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/Pattern'), 'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__).'/Pattern/Partials'), 'helpers' => array('i18n' => function($text) { // do something translatey here... }), 'escape' => function($value) { return htmlspecialchars($value, ENT_COMPAT, 'UTF-8'); }, 'logger' => new Mustache_Logger_StreamLogger('php://stderr'), 'strict_callables' => false, )); call that _init_mustache.php in the _init.php include_once("./_init_mustache.php"); Now I have a site/template/portfolio.php where I call the template $tpl = $mustache->loadTemplate('02-objects-050-image-hovertext'); // loads __DIR__.'/views/foo.mustache'; $content .= $tpl->render(array( 'alltagstitle' => $alltagtitle, 'order' => '01', 'Title' => $title, 'SRC' => $resized_thumb->url, )); this works so far in mysite.com/portfolio but I also call it from here fields/gcp/portfolio.php $temp = wireRenderFile($config->paths->templates.'/portfolio.php'); $search = explode(",", $srch); $replace = explode(",", $rplc); $newtemp = str_replace($search, $replace, $temp); echo $newtemp; to include the portfolio part on other pages. (I use the module “fieldtype select file”) My problem is now, that on the page where I use that last method I get the error: Error: Call to a member function loadTemplate() on null (line 71 of /var/…./site/templates/portfolio.php) And the Notice: Notice: Undefined variable: mustache in /var/www/clients/client29/web166/web/eyeonu-v6/site/templates/portfolio.php on line 71 Fatal error: Call to a member function loadTemplate() on null in /var/www/clients/client29/web166/web/eyeonu-v6/site/templates/portfolio.php on line 71 line 71 is: $tpl = $mustache->loadTemplate('02-objects-050-image-hovertext'); // loads __DIR__.'/views/foo.mustache'; It looks that I somehow messed it up with the prependtemplatefiles, can anyone give me a tip?
-
Hi, I'm curious if anyone has implemented some sort of template ala twig, liquid, mustache, handlebars etc. so on and so forth? I noticed a blog post about blog themes which needed to be easier to work with than WP and using a simplified template syntax would definitely help for non-php-ers.
- 74 replies
-
- template engine
- twig
-
(and 8 more)
Tagged with: