开发者

Make the view render an html substring

I've got the following controller

def detail
    @book = get_book_details(params[:asin])

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @booklists }
    end
end

the unbundle lib get_book_details(asin), return a "book = Hash.new" like this:

book[:title]
book[:editorial_reviews] 
book[:total_reviews] 
... 

and so on. In the view, I get the following

<%= h @book[:editorial_reviews]%>

The problem is that the content of @book[:editorial_reviews]开发者_开发百科 is actually an HTML

substring, containing some fews tags I'd like to render.

Like that, I'll get those tags into the client browser view, but not interpreted and

sanitizing the string, result in missing some formatting layout which I'd like to

display instead.

How can I make the view render that inside html tags ???

Sorry for the newbie question. Thanks in advance lgs


The h method escapes all the html tags. If you remove it, your html tags won't be escaped.
And you'll have your content appropriately formatted.

<%= @book[:editorial_reviews] %>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜