jekyll-haml icon indicating copy to clipboard operation
jekyll-haml copied to clipboard

Tag attributes are not being interpolated

Open EvanAgee opened this issue 8 years ago • 3 comments

Hello! First off thanks for creating this, love it!

The issue I'm having is that when I use liquid to assign a value to a tag attribute it's not being interpolated correctly. For example:

%a.button.filled.color-yellow{ href: "{{ '/venue' | relative_url }}" }

is returning an anchor with an empty href attribute. However if I move that liquid tag into the contents of the anchor it renders correctly.

Any assistance you can provide?

EvanAgee avatar Jun 14 '17 16:06 EvanAgee

Hi,

I had trouble also with interpolations, I made a gem with a slightly different approach https://github.com/afaundez/jekyll-haml-markup.

It had a lot of work to do, but I'm willing to maintain it.

afaundez avatar Feb 06 '18 21:02 afaundez

@EvanAgee did you ever figure this out?

jbschrades avatar Jun 29 '18 16:06 jbschrades

I assume that your string is being escaped from "{{ '/venue' | relative_url }}" to "{{ '/venue' | relative_url }}" and being ignored.

In rails it would overcome with simply adding "{{ '/venue' | relative_url }}".html_safe.

But in jekyll where is no such function for string, put this in _plugins/string_helpers.rb to obtain it:

class String
  def html_safe?
    defined?(@html_safe) && @html_safe
  end

  def html_safe
    @html_safe = true
    self
  end
end

require 'haml/helpers/xss_mods'

module Haml::Helpers
  include Haml::Helpers::XssMods
end

Credits for answer going here, look there for details.

astery avatar Jul 04 '18 12:07 astery