I just asked a question ( Templates In Kohana 3.1 ) about templates and now I know that I should use Kostache. It’s a module for the Mustache template language.
Anyway, I just enabled Kostache module for my Kohana 3.1 and all works. It’s installed correctly! What to do next? How to use it?
Where should I put my views now?
What my controller should extend?
How to assign variable?
How to make header, footer etc. for views?
Maybe there are step to step guide for it? This and this won’t help me a lot…
View classes contain logic for your templates and by convention should be stored in
classes/view/{template name}.phpTemplates contain your HTML and should be stored in the
templatesdirectory in the root of your module, e.g.templates/login.mustacheBy default kostache will try and work out the location of the template based on your view class’ name.
If your view class is called
View_Admin_Loginthen kostache will look fortemplates/admin/login.mustacheYou do not need to extend any special controllers, the normal
Controllerwill work fine as a base.Controller:
Template:
Of course, any methods or variables you declare in your view class will also be available in
the template. If there is a class variable and method with the same name then the method will always take precedence over the variable.
It will help if you read the kostache guide. The idea is that your views extend
Kostache_Layout, see also the layout template