When to use Helpers instead of Partials

后端 未结 6 371
不知归路
不知归路 2020-12-05 13:03

In a rails application, in which situation would you use a partial and when would you use a helper? I find both very similar, since they represent markup fragments.

6条回答
  •  广开言路
    2020-12-05 13:37

    The other answers represent the conceptual consensus regarding the use of helpers vs. partials. Consider the following for further reading:

    Basecamp dev making the case for minimizing HTML in helpers http://37signals.com/svn/posts/1108-what-belongs-in-a-helper-method

    Viget dev benchmarked each and found that helpers are faster than partials http://www.viget.com/extend/helpers-vs-partials-a-performance-question/

提交回复
热议问题