狂欢破坏电子邮件文本模板

时间:2013-10-02 19:33:55

标签: ruby-on-rails spree deface

我想在结帐电子邮件后插入文字。我在spree / order_mailer / confirm_email.text.erb

中找到了模板
<%= Spree.t('order_mailer.confirm_email.dear_customer') %>

<%= Spree.t('order_mailer.confirm_email.instructions') %>

============================================================
<%= Spree.t('order_mailer.confirm_email.order_summary') %>
============================================================
<% @order.line_items.each do |item| %>
<%= item.variant.sku %> <%= raw(item.variant.product.name) %> <%= raw(item.variant.options_text) -%> (<%=item.quantity%>) @ <%= item.single_money %> = <%= item.display_amount %>
<% end %>
============================================================
<%= Spree.t('order_mailer.confirm_email.subtotal', :subtotal => @order.display_item_total) %>

<% @order.adjustments.eligible.each do |adjustment| %>
  <%= raw(adjustment.label) %> <%= adjustment.display_amount %>
<% end %>

<%= Spree.t('order_mailer.confirm_email.total', :total => @order.display_total) %>

<%= Spree.t('order_mailer.confirm_email.thanks') %>

所以我不知道如何在此之后添加一些文本,没有任何选择器:

Deface::Override.new(
    :virtual_path => "spree/order_mailer/confirm_email",
    :insert_bottom => '*',
    :partial      => "spree/shared/confirm_email",    
    :name         => "confirm_email",
    :original     => '3a8c298b4d9884a4d9f842b23fcb4fabf92ef0f3'
)

你能告诉我任何方法来解决这个问题吗?

2 个答案:

答案 0 :(得分:3)

在此处找到解决方案:How to add Spree email attachment (image) from products.images?。我创建了一个新模板/app/views/spree/order_mailer/confirm_email.text.erb,并在此处添加了我的代码。

答案 1 :(得分:0)

简短的回答:你不能。

长答案:遗憾的是,我最近尝试过,你不能破坏文本文件。原因是 Deface需要结构化数据来解析视图,详见Spree Group discussion。 只有.deface,.html.erb.deface,.html.haml.deface或.html.slim.deface是唯一允许的覆盖文件:

Deface::DSL does not know how to read '/spree/app/overrides/spree/order_mailer/confirm_email.text/append_text.text.erb.deface'. 
Override files should end with just .deface, .html.erb.deface, .html.haml.deface or .html.slim.deface

有趣的是,deface实际上能够测试文件上的选择器,但仍然无法覆盖:

$ bundle exec rake deface:test_selector['spree/order_mailer/confirm_email.text',"erb:contains('order_mailer.confirm_email.thanks')"]

Querying 'spree/order_mailer/confirm_email.text' for 'erb:contains('order_mailer.confirm_email.thanks')'
---------------- Match 1 ----------------
<%= Spree.t('order_mailer.confirm_email.thanks') %>

您唯一可以做的就是通过创建app/views/spree/order_mailer/confirm_email.text.erb

来覆盖该文件