1

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"))
  • are you getting an error ? what's the exact output that is being produced by the above code ? – xyious Jun 07 '16 at 01:28

1 Answers1

1

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

Ropeney
  • 1,065
  • 8
  • 10
  • You're not running the text through yet another erb interpreter, especially since you're inside a ruby interpreter right now. – xyious Jun 07 '16 at 01:28
  • Did you confirm this or just guessing? https://github.com/spree/deface under examples number 3 seems to suggest otherwise, so does every time I've used it. – Ropeney Jun 07 '16 at 01:30
  • I was just guessing but the examples in the link you posted agree with you. Could you edit your answer and throw that link in there ? – xyious Jun 07 '16 at 01:32
  • I stand by my downvote with the information I had. You have given me more information and I now agree with your answer. – xyious Jun 07 '16 at 01:35