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
1
vote
1 answer

Dynamically generated HTML (Server-side) in new page

For learning purposes, I am building a simple web app that allows users to write an introduction page for themselves. I am very confused about dynamically generated HTML on the server-side and how it connects to the client-side. I am currently…
Alan
  • 313
  • 4
  • 14
1
vote
0 answers

Cant escape PHP code in mustache variables

I'm using the PHP version of mustache, and also patternLab - which I think also uses the PHP version of mustache. example 1 : PHP version of mustache I've also tried using the escape option, to no avail Using triple {{{}}} doesn't work…
Ashleigh
  • 35
  • 7
1
vote
0 answers

php Mustache Template switch logic

So. I did see this question: How to use switch case in Mustache template? Goal flow: php sets variables then calls up mustache template. Currently its php jumbled with html and calls up mustache templates. My question is about this sort of logic: …
theamycode
  • 219
  • 3
  • 10
1
vote
0 answers

How to dynamically load partials in Mustache PHP?

I'm having trouble finding decent docs on loading partials programmatically through Mustache. I'm trying to load a login page with the form being a partial (it'll change depending on different user interactions). PHP: $m = new…
Chris R.
  • 699
  • 8
  • 23
1
vote
1 answer

How to show specific value from array with mustache?

I have an array like: Array ( [0] => Array ( [title] => Title 1 [value] => Value 1 [id] => 1428735262 ) [1] => Array ( [title] => Title 2 [value] => Value…
Dev01
  • 4,082
  • 5
  • 29
  • 45
1
vote
1 answer

how to limit iterations in mustache

I have this mustache template: {{#pages}} {{/pages}} Now there are more than 50 pages but I want to be able to show only 10 pages. How to do that in…
Dev01
  • 4,082
  • 5
  • 29
  • 45
1
vote
1 answer

looping through two dimensional array and passing to mustache template

so I am just getting started using mustache.php and I am stuck trying to loop though a two dimensional array. I have an array that looks like this... $FeedArray = array(3) { [0]=> array(3) { ["entity"]=> string(10) "mail" …
ambe5960
  • 1,870
  • 2
  • 19
  • 47
1
vote
1 answer

Dynamic Navigation with Mustache Templating

I have created a template with mustache.php and am wanting to dynamically create my navigation based on files within a single folder. I am using codeigniter for this project. I have a function that fetches the files and turns them into links, this…
moevans
  • 79
  • 1
  • 2
  • 6
1
vote
3 answers

Can I use a Mustache var in a partial name?

I currently use a template for multiple pages (basic.mustache) and everything work great, but I want to add different boxes (box1.mustache, box2.mustache) in a sidebar depending of the page. Basically, I would need to add the mustache templates in…
Simon Arnold
  • 15,849
  • 7
  • 67
  • 85
1
vote
1 answer

How to access a specific index of an array in a mustache template, when that specific index is stored in another variable?

Say i have an fruits object i'm passing to a mustache template. fruits = { 0 => {name: apple} } I can do this in the mustache template and all is well fruits.0.name BUT what if that index is another variable like i, how do i access that…
rsahai91
  • 437
  • 4
  • 13
1
vote
2 answers

Is it possible to let Mustache (php) partials contain their own data?

I want to have a Mustache template reference a partial where the partial adds data to the context as well. Instead of having to define the data in the data to the initial Mustache rendering. I have a mockup in…
Lode
  • 2,160
  • 1
  • 20
  • 25
1
vote
1 answer

How to override partials with Mustache

I've just started with Mustache.php and I'm looking for a way to add to my Mustache.php loader an override feature like the one used in Joomla. I'm loading partials from the directory "views" and I'd like to tell to Mustache to read first the…
Fez Vrasta
  • 14,110
  • 21
  • 98
  • 160
1
vote
1 answer

Mustache not iterating over array

I don't know what is going on (maybe it because it is the 12th consecutive hour working). I always used this notation but now it just doesn't work (I already checked several time that the data is passed to this template I'm talking about). Data is…
Damiano Barbati
  • 3,356
  • 8
  • 39
  • 51
1
vote
1 answer

Check value of the mustache variable in helper

I've JSON with the price and currency name, like this: [{"price": 123, "currency": "RUR"}, {"price": 456, "currency": "USD"}, {"price": 789, "currency": "EUR"}] Also, i use Mustache.php to render them. {{price}} {{currency}} as template and…
1
vote
1 answer

working with php and javascript templates

Currently I am use the slim framework to serve html templates to the browser. After the view is loaded the application retrieves some information from a RESTful API and uses handlebars.js to populate various aspects of the DOM. I would like to use a…
TheLastEmperawr
  • 652
  • 8
  • 22