# Modularisation: Using helper generating HTML output vs. using partials

**URL:** <https://www.ruby-forum.com/t/modularisation-using-helper-generating-html-output-vs-using-partials/151083>\
**Category:** Rails\
**Created:** [October 16, 2008, 4:37pm UTC](https://www.ruby-forum.com/t/modularisation-using-helper-generating-html-output-vs-using-partials/151083 "2008-10-16T16:37:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![msmsms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@msmsms](https://www.ruby-forum.com/u/msmsms)\
**Post date:** [October 16, 2008, 4:37pm UTC](https://www.ruby-forum.com/t/modularisation-using-helper-generating-html-output-vs-using-partials/151083/1 "2008-10-16T16:37:28Z")

</div>

Hey,

I’ve got a general question: when do I use helper and when I do use  
partials to modularise certain gui elements?

For example: I’ve got a faq list. Each item can be folded and unfolded  
using ajax.

FAQ foo  
-\> question 1  
-\> question 2  
-\> question 3

So, I wrote a helper “faq\_li\_tag(args)” which takes the question and  
answer for parameters and generates the HTML output.

But I also could have made a partial which creates the corresponding  
output.

What’s the best solution? What are the criterias for this decision in  
general?

Thank you very much!

Best regards,  
ms

---

<div class="post-metadata">

**Author:** ![msmsms](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/34f0e0/32.png) [@msmsms](https://www.ruby-forum.com/u/msmsms)\
**Post date:** [October 16, 2008, 5:18pm UTC](https://www.ruby-forum.com/t/modularisation-using-helper-generating-html-output-vs-using-partials/151083/2 "2008-10-16T17:18:04Z")

</div>

On Oct 16, 9:22 am, ms [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> → question 2
> 
> Thank you very much!
> 
> Best regards,  
> ms

I use partials to factor out view templates to make them more  
readable, and so that I can reuse portions of a view in other  
templates.

I use helpers whenever view logic is starting to get intertwined with  
the view code. So presentation-only code is in the views/partials,  
and any logic (is this user an admin? should they see a sidebar now?  
etc.) goes into helpers.

Jeff

[purpleworkshops.com](http://purpleworkshops.com)

> **[Hey Daddio!](http://softiesonrails.com)**
>
> Home of Hey Daddio Software
