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
0
votes
0 answers

Configurable partial

I have a component in my templating engine (that works well so far) that kind of needs to take an argument. The component is a navigation on a website. In the CMS there can be many navigations (main, footer, side) but I can't get the logic for…
Moseleyi
  • 2,585
  • 1
  • 24
  • 46
0
votes
1 answer

Newbie Question - php & mustache iteration

I am having difficulty iterating over an array of data. My Code is as follows: $root = $_SERVER['DOCUMENT_ROOT']; require…
M Becker
  • 73
  • 5
0
votes
1 answer

output a group of option tags 1 through 10

I have a group of option tags inside a select. Is there a way to generate these tags for x to y using mustache? The only way I could think of now is to create an array from 1 to 10 in the controller, then use that variable as a section in the…
K.G.
  • 59
  • 5
0
votes
1 answer

Mustache templeting Probrem with Nested Object

I have problem with mustache to render data after ajax success. and i have return json file like this { "Malaysia-office": { "office_name": "Malaysia-office", "employee": [ { "capacity": 3600, …
Bonny AUlia
  • 95
  • 2
  • 10
0
votes
2 answers

How to iterate over array of objects with private properties in Mustache properly?

Example of mustache template: {{#entites}} {{title}} {{/entities}} Rendered by: $m = new Mustache_Engine( ['loader' => new Mustache_Loader_FilesystemLoader('../views')] ); echo $m->render('index', $data); Basic nested…
Codium
  • 3,200
  • 6
  • 34
  • 60
0
votes
1 answer

PHP Mustache - multiple partials

I found this fiddle that shows how to include multiple partials in a Mustache template: http://jsfiddle.net/YW5zF/3/ I'm trying to convert this to PHP Mustache and having some difficulty. Can anyone help out here? Essentially, I'm trying to…
MB34
  • 4,210
  • 12
  • 59
  • 110
0
votes
2 answers

Mustache.php rendering multi-dimensional data

I'm utilizing Mustache to template some XML responses for an API. I was wondering how I could use the XML template below to render data from this array? The data is not rendering at all when using this code: $result = $m->render($template, $r); …
MB34
  • 4,210
  • 12
  • 59
  • 110
0
votes
1 answer

PHP Mustache Dynamic partials and partial collections

Has anyone found a way to dynamically render partials? I found this link for mustache.js but I am unsure how to implement this in php or if there is even away to do this in php. Even if it was the boolean flag method in the example in the link. The…
Zack Arnett
  • 239
  • 2
  • 6
  • 19
0
votes
1 answer

Mustache.php initiated from within a namespace - include(): failed to open stream

When using a simple autoloader, Mustache.php initiated from within a namespace webpage renders the data properly but also returns a long list of warnings about failures to include many of its files. Mustache is loaded by requiring its…
Glen
  • 87
  • 9
0
votes
1 answer

Render Mustache PHP template with Doctrine entity model

In my Symfony controller I want to render a Mustache PHP template, with a Doctrine entity: // The Doctrine entity, a dump($user) shows the correct entity $user = $this->get('x_service')->getUserById($id); $templateFile =…
BigJ
  • 1,990
  • 2
  • 29
  • 47
0
votes
1 answer

How to use mustache php to render unadulterated mustache js template with curly braces intact

I want to render a javascript mustache template in mustache php. How do I render {{foo}} inside of script tags from php mustache with the {{foo}} curly braces being escaped, so that I can later render it as mustache.js template?
deusoz
  • 165
  • 2
  • 7
0
votes
0 answers

Looping data with Mustache

I'm working on a project called Mijn Paneel. Its in dutch and its a sort of socializing backend of a themepark minecraft server. The first version was written in pure php. This time I am doing a rewrite. (And my first time with composer) My…
0
votes
1 answer

PHP Mustache pass a variable to a function

I want to pass a variable to a function: {{#myFunc}}{{someVar}}{{/myFunction}} This is my engine: $options = [ 'helpers' => [ 'myFunc' => function($value) { // This works return 'got value: ' . $value; …
Kousha
  • 32,871
  • 51
  • 172
  • 296
0
votes
0 answers

Remove the decimal in the value inside mustache

I'm trying to create a template where one of a text box's value is: value="{{selection_qty}}"; the value of {{selection_qty}} is decimal I want to remove the decimal.How could I do it using php? I tried to put it inside php code but it didn't…
Dean
  • 23
  • 7
0
votes
2 answers

Front page in Pattern Lab

I am interested in adding a front page to Pattern Lab. Rather than starting with the contents in "Atoms" (see image), I would like to start with a style guide. I tried adding a folder, "Main", before "Atoms" with a mustache file, but (1) I was…
c.doe
  • 1