[英]Rails and HAML: Mailto link with picture
我正在嘗試創建一個mailto鏈接,其中涉及單擊圖片,並將一些原始內容從文本文件包含到郵件正文中。
以下無效(haml)。
= mail_to "friend@example.com" do
%img{:src=>"#{asset_path 'mail.png'}"}
我什至不知道如何將屍體預裝在那里。 我知道有一個:body
聲明,但是在此上下文中它的使用使我難以理解。
有什么想法嗎?
在Rails 4中 , mail_to
幫助器似乎只接受一個阻止 ,而不是以前的版本 。 如果您使用的是Rails 3並且無法升級,則可以執行以下操作:
- mail_link_content = capture_haml do
%img{:src=>asset_path('mail.png')}
=mail_to "friend@example.com", mail_link_content
請注意,如果內容全部都是插值的,則無需使用字符串(不過,您可能需要添加括號)。
要獲取正文內容,您只需要使用:body
鍵將options哈希作為最后一個參數傳遞給mail_to
:
Rails 4:
= mail_to "friend@example.com", :body => "Body text here" do
%img{:src=>asset_path('mail.png')}
Rails 3:
=mail_to "friend@example.com", mail_link_content, :body => "Body text here"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.