inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

details_link does not allow variable input #356

Closed iwishiwasaneagle closed 9 months ago

iwishiwasaneagle commented 9 months ago

Currently the details_link tag requires the actually bibtex tag such as {% details_link made_up_2023 %} which isn't very useful when trying to make a referencing template that includes it.

Having it also accept a variable such as {% details_link entry %} (such as the decrement tag) would be massively useful.

Alternatively, having a block (like BibTexTag or QuouteTag) alternative would also work since you can then echo the variables within it like {% details_link %} {{entry.tag}} {% enddetails_link %}.

Something like the below should work:

module Jekyll
  class Scholar
    class DetailsLinkBlock < Liquid::Block
      include Scholar::Utilities

      def initialize(tag_name, arguments, tokens)
        super

        @config = Scholar.defaults.dup
        @keys, arguments = split_arguments arguments

        optparse(arguments)
      end

      def render(context)
        set_context_to context
        details_block super.strip
      end
    end
  end
end

Liquid::Template.register_tag('details_link', Jekyll::Scholar::DetailsLinkBlock)
iwishiwasaneagle commented 9 months ago

Never mind. This works with the original tag {% details_link entry.tag %} . I had an empty {% details_link %} leftover from debugging that was causing the issues.