1- #CakePan
1+ # CakePan - CakePHP Mustache Support (CakePHP v2.x)
22
33CakePan is a CakePHP view helper that renders Mustache templates. It will also load and process sub-templates!
44
@@ -17,13 +17,11 @@ CakePan should be added to your project the same as any other CakePHP View Helpe
1717
1818If you want to add Mustache support globally, add it to your ` AppController `
1919
20- ``` php
21- class AppController extends Controller {
22- ...
23- public $helpers = array('Mustache');
24- ...
25- }
26- ```
20+ class AppController extends Controller {
21+ ...
22+ public $helpers = array('Mustache');
23+ ...
24+ }
2725
2826## Usage
2927
@@ -47,14 +45,13 @@ Your Mustache templates should all be in the `/app/View/Elements/` directory, wi
4745
4846All the variable set by the controller are available, and merged with values passed into ` $params ` .
4947
50- ``` php
51- $params = array(
52- 'title' => 'Show me the bacon!',
53- 'text' => 'Bacon ipsum dolor sit amet fatback pig swine...'
54- );
48+ $params = array(
49+ 'title' => 'Show me the bacon!',
50+ 'text' => 'Bacon ipsum dolor sit amet fatback pig swine...'
51+ );
52+
53+ $this->Mustache->element('template_name', $params)
5554
56- $this->Mustache->element('template_name', $params)
57- ```
5855
5956
6057### Sub-templates
@@ -63,17 +60,15 @@ Sub-templates should follow the same naming convention. Mustache will pass the v
6360
6461/views/elements/posts/post.mustache:
6562
66- ``` mustache
67- {{#Post}}
68- <h2>{{title}}</h2\>
69- <div>
70- {{text}}
71- </div>
72- {{/Post}}
73- {{#Comment}}
74- {{>post/comment}}
75- {{/Comment}}
76- ```
63+ {{#Post}}
64+ <h2>{{title}}</h2\>
65+ <div>
66+ {{text}}
67+ </div>
68+ {{/Post}}
69+ {{#Comment}}
70+ {{>post/comment}}
71+ {{/Comment}}
7772
7873/views/elements/posts/comment.mustache:
7974
0 commit comments