2012-05-07 2 views
7

HAML 템플릿에 대해이 도우미가 잘못되었습니다. 이 같은haml_tag가 Haml 템플릿에 직접 출력합니다.

haml_tag outputs directly to the Haml template. 
Disregard its return value and use the - operator, 
or use capture_haml to get the value as a String. 

템플릿이 호출 display_event : 나는 정기적으로 마크 업을 사용하는 경우

- @events.each do |event| 
    = display_event(event) 

는 다음

%li.fooclass 
    %b Foo 
    %i Bar 
으로 확장 할
def display_event(event) 
    event = MultiJson.decode(event) 
    markup_class = get_markup_class(event) 
    haml_tag :li, :class => markup_class do 
     haml_tag :b, "Foo" 
     haml_tag :i, "Bar" 
    end 
    end 

오류입니다

답변

10

실마리에 단서가 있습니다. R 메시지 : haml_tag에 대한 문서에서

Disregard its return value and use the - operator, 
or use capture_haml to get the value as a String. 

:

haml_tag outputs directly to the buffer; its return value should not be used. If you need to get the results as a string, use #capture_haml .

이 HAML 그것을 수정하거나 변경하려면에 :

- @events.each do |event| 
    - display_event(event) 

(즉, capture_haml를 사용하는 방법) 대신 =- 연산자를 사용하거나 변경 :

def display_event() 
    event = MultiJson.decode(event) 
    markup_class = get_markup_class(event) 
    capture_haml do 
    haml_tag :li, :class => markup_class do 
     haml_tag :b, "Foo" 
     haml_tag :i, "Bar" 
    end 
    end 
end 

이 방법은 당신이 다음 HAML의 =로 표시 할 수있는 문자열을 반환 할 것입니다.

이 변경 사항 중 하나만으로 설정해야합니다. 두 설정을 모두 취소하면 아무 것도 표시되지 않습니다.