目前我有鐵路後端骨幹RIA。我使用haml_coffee_assets gem進行客戶端模板。但我想念那裏的鐵觀點幫手。如何將原始html字符串屬性嵌入到.hamlc模板中?
我決定將原始html字符串添加到我的主幹模型中。 所以,我有這樣的對象在我的CoffeeScript
Object
avatar: "/avatars/small/missing.png"
avatar_link: "<a href="https://stackoverflow.com/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="https://stackoverflow.com/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}
但事實並非如此似乎工作。
剛剛在這裏找到了答案: http://stackoverflow.com/questions/9201593/partials-in-coffee-haml-hamlc – Ortepko