Arrian Ebrahimi
Arrian Ebrahimi

Reputation: 41

Adding an image with Deface::Override to Spree

I was able to insert some text after a <div> by using a Deface::Override but now I want to add an image of a QR code instead of text. How would you change this code to work for an image? My original code that successfully added text is the first block, and my second one where I try to add an image is the second. Thank you very much!

Here is the first one that does work:

Deface::Override.new(:virtual_path  => "spree/home/index",
                 :replace => "[data-hook='homepage_products']",
                 :name          => "homepage_contents",
                 :text          => "La registration, c'est le futur!")

And here's the second that doesn't work:

Deface::Override.new(:virtual_path  => "spree/checkout/_address",
                 :insert_after => "[data-hook = 'shipping_fieldset_wrapper']",
                 :name          => "add_qr_code",
                 :text          => image_tag("assets/images/qr_code.png"))

Upvotes: 1

Views: 331

Answers (1)

Ropeney
Ropeney

Reputation: 1065

I believe you need to supply the erb tags <%= ... %> to get it to work or it'll add raw HTML.

Try:

Deface::Override.new(:virtual_path  => "spree/checkout/_address",
                 :insert_after => "[data-hook = 'shipping_fieldset_wrapper']",
                 :name          => "add_qr_code",
                 :text          => "<%= image_tag('assets/images/qr_code.png') %>")

https://github.com/spree/deface for examples

Upvotes: 1

Related Questions