Questions tagged [mustache.php]

A Mustache (logic-less templating system for HTML) implementation in PHP.

mustache.php is an implementation of in PHP. It requires at least PHP 5.2.x.

You can find more information about Mustache on the official website.

Installation

It can be easily installed using :

{
    "require": {
        "mustache/mustache": "2.0.*"
    }
}

An example

<?php
$m = new Mustache_Engine;
echo $m->render('Hello {{planet}}', array('planet' => 'World!'));
// will print: "Hello World!"

Links

94 questions
2
votes
1 answer

How to handle selects sensibly in ractivejs?

We are looking to (re)build a web app. We would like to make it isomorphic, so the server can render the same templates but a javascript state model would exist and handle updates. Am looking at ractivejs and mustache/handlebars as one fairly…
Adam
  • 6,539
  • 3
  • 39
  • 65
2
votes
1 answer

making a model from table mySQL with PDO

I am developing an application for fun, and I am purposefully NOT using any frameworks aside from mustache for PHP and JS, etc on either the client or server side of the modest application. Each view has a table which holds all data used for each…
AlphaG33k
  • 1,588
  • 1
  • 12
  • 24
2
votes
0 answers

PHP Mustache array of object accessing

JSON data { "product_list": [ { "title": "Title Name", } , { "title": "another title" } ] } Mustache…
varuog
  • 3,031
  • 5
  • 28
  • 56
2
votes
1 answer

PHP Form - Uploading Files, wanting to use Silex but not FormBuilder

I'm using Silex to build an app, though it's not the typical Silex setup. I've got Mustache as the templating engine. I'm not using Doctrine for ORM / DBAL, I'm using Capsule (Silex-Eloquent), and am having some serious trouble wrapping my head…
2
votes
0 answers

How To render Mustache Partial in zf2

I'm using this module https://github.com/widmogrod/zf2-mustache-module module.config 'strategies' => array( 'Mustache\View\Strategy' ), 'template_map' => array( 'My_Main' => __DIR__ . '/../view/main.phtml', 'My_SideBar' => __DIR__ .…
Defyleiti
  • 535
  • 1
  • 7
  • 23
2
votes
1 answer

How to use loops with Mustache.php?

I need to loop as foreach() with my array, $input = array ( 1 => array ( 'year' => '1534', 'name' => 'test1', ), 2 => array ( 'year' => '1644', 'day' => 'test2' ) 3 => array ( 'year' => '2015', 'day' => 'test3', ), …
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
2
votes
1 answer

Rendering Mustache Block with external templates

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 …
Simon Arnold
  • 15,849
  • 7
  • 67
  • 85
2
votes
1 answer

How make logical if and else with a parameter value in mustache

How make logical if and else with a parameter value in mustache ? like : if ($a == "yes") action else action or like, if ($a == "yes") action else if ($a == "maybe") else action
1
vote
0 answers

Preg matching mustache lambdas and other "complex" mustache variables

Before we were using mustache for template rendering, we had a PHP class that we used to translate text for localization. What it basically did, is that it accepted a variable number of parameters, searched for the translation for the first…
Adam Baranyai
  • 3,635
  • 3
  • 29
  • 68
1
vote
1 answer

Mustache Php: partials constructor not working

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…
k.wig
  • 39
  • 1
  • 7
1
vote
1 answer

Can we edit a mustache template in runtime?

Can I add new nodes to mustache template at run-time in PHP? Let's say below is a code where ProductDetails will contain few single products: {{#ProductDetails}} {{#SingleProduct}} {{OldDetail}} {{/SingleProduct}}…
learning_13
  • 140
  • 7
1
vote
2 answers

PHP - validate mustache template

How do I validate a mustache template string in PHP? For example, if I pass Hi {{#name}}{{name}}{{/name}}{{^name}}guest{{/name}} and the validator should return valid, but if I pass Hi {{#name}}{{name}}{{/name}}{{^name}}guest it should return…
Kousha
  • 32,871
  • 51
  • 172
  • 296
1
vote
1 answer

How to update the template loader path in Mustache?

I am trying to define an alternative/default template loader path in case the first one is not found. Currently I initialize mustache this way: $m = new Mustache_Engine(array( 'loader' => new…
gdaniel
  • 1,307
  • 2
  • 10
  • 17
1
vote
2 answers

Mustache php space in templates

I have this template code: {{#album}}

{{ hinfo.artist_name }}

{{ hinfo.name }}

{{/album}} which renders:

Instead if I write: {{#album}}

{{hinfo.artist_name}}

{{hinfo.name}}

{{/album}} it…
Evhz
  • 8,852
  • 9
  • 51
  • 69
1
vote
0 answers

Mustache Js: Uncaught Error: Syntax error, unrecognized expression

This is my template