With the examples you have given, it seems that what it's trying to is 
better accomplished with a small partial. You'd probably can even use 
render in helpers if that syntax would make you happier :)

Or am I just missing the point here

On Friday, April 22, 2016 at 1:59:12 PM UTC+3, Richard Hulse wrote:
>
> Hi!
>
> I have some thoughts around the use of HEREDOCS to construct blocks of 
> HTML in helpers (or decorators) I'd like some feedback on before filing a 
> bug/feature request.
>
>
> This kind of construct is bad:
>
> "<div class="foo">#{content}</div>".html_safe
>
> We should really do this:
>
> content_tag(:div, content, :class => 'foo')
>
> or this:
>
>   html = "".html_safe
>   html << "<div class='foor'>".html_safe
>   html << content
>   html << "</div>".html_safe
>
> For longer blocks of HTML where there is a lot of logic required to get 
> the pieces content going into it, both of the above quickly become unwieldy 
> and hard to maintain.
>
> Should we be able to do this:
>
> [some logic that generates title, content, tags]
>
> <<~HTML
>   <div>
>     <h4>#{title}</h4>
>     <p>#{content}</p>
>     <p>#{tags}</p>
>   </div>
> HTML
>
> ...and have all interpolated content be marked as unsafe?
>
> Doing this:
>
> <<~HTML.html_safe
>
> is a Bad Things to be avoided.
>
> I'd be inclined to leave regular interpolated strings as is.
>
> Could this be better dealt with with a new .unsafe method?
>
>
> Cheers,
>
> Richard
>
>
>
>
>
>
>
>
>  
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to