2013-05-06 4 views
0

'.html_safe'를 포함하면 스타일 지정 (lass = 'lead'style = 'font-size : 14px;')이 사용되지 않습니다. .html_safe를 제거하면 스타일이 적용되지만 이제 모든 HTML이 표시됩니다.레일즈 앱에서 html_safe로 스타일을 수정하는 방법은 무엇입니까?

해결 방법에 대한 조언이 있으십니까? HTML없이 @의 chapter.chaptext의

<p class = 'lead' style = 'font-size: 14px;'> 
     <div id = 'textcontainer'> 
      <%= @chapter.chaptext.html_safe %> 
     </div> <!-- end of textcontainer div --> 
    </p>  

콘텐츠 : @chapter.chaptexttextcontainer 내부 문자열로 표현되고 있기 때문에

<p> Sanjaya said: <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>Lord Krishna</a></a></a></a></a></a></a></a></a> spoke these wor<a href = '#' class = 'getannotation'>ds to Arjuna</a> whose eyes were 
<a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>tearful and downcast</a></a>, and who was ov<a href = '#' class = 'getannotation'>erwh</a>elmed <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>with compassion and despair</a></a>. 
(2.01) <p> 

<p> The Supreme Lord said: How has the dejection come to you at this 
juncture? This is n<a href = '#' class = 'getannotation'>ot fit for an Arya</a>n (or the people of noble mind and 
deeds). It is disgraceful, and it does not lead one to heaven, O Arjuna. 
(2.02)<br> 

<p> Do not become a coward, O Arjuna, because it does not befit you. Shake 
off this weakness of your heart and get up (for the battle), O Arjuna. 
(2.03) <p> 
+0

'<% = @ chapter.chaptext.html_safe %> '의 HTML 출력을 표시 할 수 있습니까? – cortex

+0

@cortex 방금 html 출력을 포함 시켰습니다. – sharataka

답변

0

.html_safe없이 작동합니다. 나는 문제가 (CSS 어디에서 온 class = 'getannotation'chaptext 콘텐츠에 적용되고 어떤 스타일 확인하기 위해 웹 관리자 도구를 사용하여 #textcontainer p { font-size: 20px;}

같은 스타일 규칙으로 나만의 스타일 (납 클래스) 또는 어쩌면 id = 'textcontainer'을 무시하고 있다고 생각 수업).

+0

예. 방금 div id 컨테이너 라인 스타일링을 변경하고 작동합니다. 감사! – sharataka

관련 문제