开发者

Partials vs for loop — best practices

开发者 https://www.devze.com 2023-01-02 10:12 出处:网络
In coding up your view templates you can render a partial and pass an array of objects to be rendered 开发者_如何学Conce per object. OR you can use a For blank in @blank loop. How do you decide when t

In coding up your view templates you can render a partial and pass an array of objects to be rendered 开发者_如何学Conce per object. OR you can use a For blank in @blank loop. How do you decide when to do which? It seems that if you use a partial for every iterable object you will end up having to modify tons of separate files to make changes to potentially one view. With the loops you can see everything right there in one file.


Generally I only use a partial for an individual object when I need to render that single object somewhere else, like in an RJS view. It keeps the views a bit easier to follow, in my opinion.

0

精彩评论

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