Kohana 3.1中的模板 [英] Templates In Kohana 3.1

查看:67
本文介绍了Kohana 3.1中的模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前我用过它们.然后我切换到加油.然后我切换回Kohana.

有问题吗?我忘记了如何正确使用模板(我的意思是Controller_Template). Kohana的文档上有教程,但现在链接似乎断开了.

请提醒我如何使用它们!

解决方案

如果您确实要使用它们,则必须扩展Kohana_Template.然后,您可以在视图名称中设置一个公共字段'$ template',然后只需执行$ this-> template-> foo ="foo"即可在模板上设置变量

public class Controller_MyController extends Controller_Template
{
    public $template = "my_view";
    public function action_foo()
    {
        $this->template->foo = "foo"
    }
}

但是核心开发人员不鼓励人们使用它.您最好使用某种模板引擎,例如 Kostache 来构成模板.

I used them before several months. Then I switched to Fuel. Then I switched back to Kohana.

Problem? I have forgot how to correctly use templates (with that I mean Controller_Template). There was tutorials on Kohana's docs, but now links seem to be broken.

Please remind me how to use them!

解决方案

If you really want to use them, you have to extend Kohana_Template. Then you would set a public field '$template' to your view name, and then just do $this->template->foo = "foo" to set variables on the template

public class Controller_MyController extends Controller_Template
{
    public $template = "my_view";
    public function action_foo()
    {
        $this->template->foo = "foo"
    }
}

But the core developers discourage people to use it. You could better use some kind of template engine like Kostache to make up your templates.

这篇关于Kohana 3.1中的模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆