home-assistant.io/plugins/linkable_title.rb
2015-02-08 15:08:41 -08:00

17 lines
400 B
Ruby

module Jekyll
class LinkableTitleTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@title = text
end
def render(context)
slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
"<a class='title-link' name='#{slug}' href='\##{slug}'></a> #{@title}"
end
end
end
Liquid::Template.register_tag('linkable_title', Jekyll::LinkableTitleTag)