bnomei
February 9, 2018, 5:10pm
1
Example Usage
site/config/config.php
c::set('plugin.mustache.helpers.page', true);
// $page object in mustache
// will merge $page->content()->toArray() with additional data
site/templates/example.mustache
<div class="c-example">
<header class="c-example__title"><h1>{{ page.title }}</h1></header>
<div class="c-example__text">{{ page.text }}</div>
</div>
content/example/example.txt
Title: Templating
----
Text: is so much fun
site/templates/example.php
c::set('plugin.mustache.helpers.page', true);
echo $page->mustache(); // or...
// mustache('example', $page->content()->toArray());
html output
<div class="c-example">
<header class="c-example__title"><h1>Templating</h1></header>
<div class="c-example__text">is so much fun</div>
</div>
More Awesomeness
Global helper function
Kirby Tag
Preview templates with dummy data using build-in dump
Change Paths
Bring in your own data not just Page Objects
Using Mustache Partials you can do Atomic Design as well
oh… and its free.
1 Like
It’s probably a great plugin… but I try to understand why a template language is needed. To me PHP is a template language.
What is the benefit of a template engine on top?
1 Like
bnomei
February 9, 2018, 8:20pm
3
certainly creating html template code can be done in plain php. but…
simple
mustache is imho as simple as a templating language can get without just being string replacement. being forced to create logicless templates really helps to apply MVC.
versatile
mustache templates can be parsed by more that one programming language. more than 40 . thats great for modern ui design systems or if you have to use one.
atomic design
using partials nesting templates can be used for basic atomic design.
mustache
it has a {{ mustache }} just like me.
1 Like
texnixe
February 9, 2018, 10:13pm
4
At least if you were forced to use a template language like this, you’d hopefully not come up with something like this .
Lol that made me laugh a lot. Yes… spare a thought for me on this cold Friday evening working with that nonsense. At least i have beer.
Just my opinion but i think it probably makes more sense to use Blade, which there is already a solution for.
texnixe
February 9, 2018, 10:30pm
7
Well, freedom of choice is always nice to have, even if it means using none of these plugins.
Cheers,
1 Like
Bottoms up!
Of course! I love a new Kirby plugin
1 Like
@bnomei Don’t get me wrong, I didn’t mean to sound ungracious. Your efforts are appreciated. I will try your plugin.
1 Like
texnixe
February 9, 2018, 11:04pm
10
1 Like
texnixe:
food for our newsletter
it is an awesome newsletter, love it when it hits my inbox.
bnomei
February 10, 2018, 8:55am
12
no worries. like with most of my plugins i take the extra mile to share them just to force myself to write better code.
1 Like
bnomei
February 10, 2018, 9:04am
13
i had to work with an existing collection of mustache templates. not creating them myself. so using blade was never an option at all. could happen to others. thats why i shared the plugin.