2017 © Pedro Peláez
 

lithium-library li3_mustache

Lithium library for rendering mustache templates

image

bruensicke/li3_mustache

Lithium library for rendering mustache templates

  • Friday, October 25, 2013
  • by d1rk
  • Repository
  • 1 Watchers
  • 4 Stars
  • 16 Installations
  • PHP
  • 1 Dependents
  • 1 Suggesters
  • 6 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

li3_mustache

Lithium library for parsing mustache views, uses PHP Mustache., (*1)

Mustache Spec version: 1.1.2 PHP Mustache version: 1.0.0, (*2)

Installation

Add a submodule to your li3 libraries:, (*3)

git submodule add git@github.com:bruensicke/li3_mustache.git libraries/li3_mustache

and activate it in you app (config/bootstrap/libraries.php), of course:, (*4)

Libraries::add('li3_mustache');

Usage

Within your views, you can easily use mustache elements with a helpful mustache helper:, (*5)

<?= $this->mustache->render('posts/detail', compact('post')); ?>

The mustache template will then be pulled from {:library}/views/mustache/posts/detail.html.php, (*6)

Any model, that is passed in (or a collection of models) will be converted to array-data at the moment, to allow for easy usage. I will work on a model-callback solution, which allows for template functions to be called., (*7)

If you want to provide the mustache template for js-usage, this can be easily done like that:, (*8)

<?= $this->mustache->script('posts/index'); ?>

This will render the following javascript block (including the template):, (*9)

<script id="tpl_posts_index" type="text/html" charset="utf-8"> { mustache template here } </script>

You can easily use this template with tpl_ followed by Inflector::slugified template name (where - will become _)., (*10)

additional usage

Instead of using only mustache for the view in general, i prefer to use mustache templates for all kind of data representation within the view, whereas i leave the view itself as default html/php mix. But this library comes with a mustache View class as well, to use mustache views completely., (*11)

Todos

The following points is my roadmap. If you need any of this features sooner than later, please let me know., (*12)

  • [✓] Provide useful helper
  • [✓] allow for easy using of an element as mustache template
  • [✓] mustache template folder to be at views/mustache
  • [✓] allow for mustache templates to live within libraries
  • [✓] allow subtemplates to be rendered, no registration required
  • [ ] provide additional scope that carries li3-relevant information (i.e. request, session, etc)
  • [ ] allow callbacks to model methods on collection data

Credits

Please report any bug, here: https://github.com/bruensicke/li3_mustache/issues, (*13)

The Versions

25/10 2013

dev-feature/handlebars

dev-feature/handlebars https://github.com/bruensicke/li3_mustache/blob/master/README.md

Lithium library for rendering mustache templates

  Sources   Download

BSD-3-Clause

The Requires

 

template mustache lithium li3

29/08 2013

dev-master

9999999-dev https://github.com/bruensicke/li3_mustache/blob/master/README.md

Lithium library for rendering mustache templates

  Sources   Download

BSD-3-Clause

The Requires

 

template mustache lithium li3

19/06 2013

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/bruensicke/li3_mustache/blob/master/README.md

Lithium library for rendering mustache templates

  Sources   Download

BSD-3-Clause

The Requires

 

template mustache lithium li3

07/06 2013

dev-engine_update

dev-engine_update https://github.com/bruensicke/li3_mustache/blob/master/README.md

Lithium library for rendering mustache templates

  Sources   Download

BSD-3-Clause

The Requires

 

template mustache lithium li3