GithubHelp home page GithubHelp logo

steffenmllr / li3_mustache Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bruensicke/li3_mustache

0.0 2.0 0.0 162 KB

Lithium plugin for rendering Mustache templates.

Home Page: https://github.com/bobthecow/mustache.php

PHP 99.12% Shell 0.12% Perl 0.74% JavaScript 0.01%

li3_mustache's Introduction

li3_mustache

Lithium library for parsing mustache views, uses PHP Mustache.

Mustache Spec version: 1.1.2 PHP Mustache version: 1.0.0

Installation

Add a submodule to your li3 libraries:

git submodule add [email protected]:bruensicke/li3_mustache.git libraries/li3_mustache

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

Libraries::add('li3_mustache');

Usage

Within your views, you can easily use mustache elements with a helpful mustache helper:

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

The mustache template will then be pulled from {:library}/views/mustache/posts/detail.html.php

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.

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

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

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

<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 _).

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.

Todos

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

  • Provide useful helper (done)
  • allow for easy using of an element as mustache template (done)
  • mustache template folder to be at views/mustache (done)
  • allow for mustache templates to live within libraries (done)
  • provide additional scope that carries li3-relevant information (i.e. request, session, etc)

Credits

Please report any bug, here: https://github.com/bruensicke/li3_mustache/issues

li3_mustache's People

Contributors

d1rk avatar nateabele avatar aaronshaf avatar steffenmllr avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.