[英]How to embed raw html string attribute into .hamlc template?
目前,我有帶有rails后端的主干RIA。 我將haml_coffee_assets gem用於客戶端模板。 但我想念Rails View助手。
我決定將原始的html字符串添加到我的主干模型中。 所以,我的咖啡腳本中有這種對象
Object
avatar: "/avatars/small/missing.png"
avatar_link: "<a href="/users/ortepko" class="author" id="user-nick-76"><img src="/avatars/small/missing.png" width="32" /></a>"
humanized_messages_number: "1 Message "
id: 76
login_name_link: "<a href="/users/ortepko" class="author" id="user-nick-76">ortepko</a>"
我的模板代碼變得非常簡單
.text_content
.comment
= @contact.avatar_link
.text
= @contact.login_name_link
.messages
%a{href: '#'}
= @contact.humanized_messages_number
現在我要渲染一個模板
JST['messages/yet_another_template'] {contact: contact}
但是它似乎沒有用。
我在這里找到了答案: 咖啡HAML(.hamlc)中的部分
我的模板應該看起來像
.text_content
.comment
!= @contact.avatar_link
.text
!= @contact.login_name_link
.messages
%a{href: '#'}
= @contact.humanized_messages_number
感謝Netzpirat!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.