开发者

Is It Okay to use helpers in views?

开发者 https://www.devze.com 2023-03-09 20:30 出处:网络
Simple question about best-practice. I\'m using Kohana... is it okay to use helpers in开发者_StackOverflow views? For example, to use URL::site(). I could pass it from controller, you know. I assume i

Simple question about best-practice. I'm using Kohana... is it okay to use helpers in开发者_StackOverflow views? For example, to use URL::site(). I could pass it from controller, you know. I assume it's okay, because there are helpers like HTML that is meant to be used in views, right?

Is It Okay to use helpers in views?


The way you're currently doing it is ok, altough the whole practice of having any logics in views is questionable, but it's how Kohana is currently recommending.

When you get to use ViewModel pattern (with Kostache?), you'll separate all logics from templates. Until then, it's ok to use methods that don't do anything that should be done in the controller / model (echo, conditions and loops are "considered allowed").

0

精彩评论

暂无评论...
验证码 换一张
取 消