문제

기본 레일 XML 빌더는 모든 HTML을 이스케이프하므로 다음과 같습니다.

atom_feed do |feed|  
  @stories.each do |story|  
    feed.entry story do |entry|   
      entry.title story.title
      entry.content "<b>foo</b>"
    end  
  end  
end

다음과 같은 텍스트가 생성됩니다.

<b>foo</b>

대신에:

XML 빌더에 XML을 이스케이프하지 않도록 지시할 수 있는 방법이 있습니까?

도움이 되었습니까?

해결책

당신이해야 할 일이 밝혀졌습니다

entry.content "<b>foo</b>", :type => "html"

CDATA로 포장하면 작동이 중지됩니다.

다른 팁

entry.content "type" => "html" do
    entry.cdata!(post.content)
end

http://builder.rubyforge.org/classes/Builder/XmlMarkup.html

XML 특수 문자 <, > 및 &는 자동으로 <, > 및 &로 변환됩니다.수정 없이 텍스트를 삽입하려면 << 작업을 사용합니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top