0

You can do this in HTML by setting the href to the a file's path and giving it a download attribute like so:

<a href="images/file.png" download>

Note that the download attribute doesn't need to be set to anything.

However, the way attributes work in HAML is different and giving it a download parameter that isn't set to anything causes an error.

%a{:href => "images/file.png", :download}

"syntax error, unexpected ')'"

I tried actually setting the download to something but for whatever reason it just redirects to the file as if it doesn't exist.

JackHasaKeyboard
  • 1,599
  • 1
  • 16
  • 29
  • 1
    This answer might have the info you are looking for: http://stackoverflow.com/a/6247375/514040 – neuronaut Oct 14 '15 at 23:41
  • Seems unnecessarily convoluted, I'd prefer to just make the download attribute work. – JackHasaKeyboard Oct 14 '15 at 23:44
  • 1
    Given the way HAML works I'm not sure you'll find anything simpler. Besides, how hard is it to do `:download => true` vs. just `:download`? (admittedly you also have to change a bit of configuration if it doesn't render the way you want, but you seem to want html output which should be the default). – neuronaut Oct 15 '15 at 00:03

1 Answers1

0

Got it to work with %a{:href => file, :download => file, :target => "blank"} all in tandem

JackHasaKeyboard
  • 1,599
  • 1
  • 16
  • 29