Monday, July 22, 2013

Re: MustacheCake - A Mustache implementation for CakePHP.

Yep, using this for all my views.

The biggest limitation I'm finding at the moment is that view blocks are not lazily loaded (they're imported in the render class's constructor), however, I'm only using blocks in layouts to grab things like "meta", "css", "scripts" and "content". This can be fixed by moving things around a little bit, and I'm thinking of the best way to do that. I'm finding that blocks are not used much when writing Mustache templates.

MustacheCake will attempt to find view (and element) files in this order:
- Using the extension specified by your controller (Controller::$ext).
- Using ".mustache".
- Using ".ctp".

If a view (or element) is found to use a ".ctp" extension, MustacheCake will be "smart" and pass it back to render using the normal Cake View::_evaluate() routine. So all your "old" templates render as usual.

Also, you can call elements using $this->_View->element('foo') in render classes to place them into Mustache templates (N.B. using Mustache partials syntax will put them through the Mustache renderer only). I have not tried going the other way, but it should work as well (i.e. call Mustache elements in ".ctp" files using $this->element('foo')).

Neat thing about this is that you can use plugins like DebugKit without recreating any of their views, while using Mustache for all your project's views and elements.

On Monday, 22 July 2013 14:06:44 UTC+10, #2Will wrote:
This is cool.  Nice one!

Are you using these for all your views? Are there any limitations you have come across using for templates? for example  Can you call elements in .ctp files from the moustache files & vice-versa?

Will



On Saturday, 20 July 2013 23:31:58 UTC+10, Dismounted wrote:
Hi all,

I've just committed a "final"-ish version of my plugin that integrates Mustache (http://mustache.github.io/) as a custom View class in Cake.

Why did I create "yet another" one of these? From what I've been able to find, other Mustache plugins either: a) implement Mustache as a view helper, not as a complete view rendering system replacement; or b) are created for older versions of Cake.

Please take a look and let me know of any suggestions/improvements/issues. To get started, there are a couple of example files in "MustacheCake/View/Layouts" and "MustacheCake/View/Pages", which are the default shipped Cake files transposed into Mustache syntax.


Cheers!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: