Class: Jekyll::HackclubMention
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::HackclubMention
- Defined in:
- lib/mentions.rb
Instance Method Summary collapse
-
#initialize(tagName, content, tokens) ⇒ HackclubMention
constructor
A new instance of HackclubMention.
- #render(context) ⇒ Object
Constructor Details
#initialize(tagName, content, tokens) ⇒ HackclubMention
Returns a new instance of HackclubMention.
6 7 8 9 10 |
# File 'lib/mentions.rb', line 6 def initialize(tagName, content, tokens) super @args = content.split(" ; ").map(&:strip) @id = @args[0] end |
Instance Method Details
#render(context) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/mentions.rb', line 12 def render(context) if @id && @id.start_with?("U") display_name = @args[1] || HackclubRequest.resolve_username(@id) %Q{<a href="https://hackclub.slack.com/team/#{@id}" class="hackclub-mention hackclub-user" target="_blank">@#{display_name}</a>} elsif @id && @id.start_with?("C") display_name = @args[1] || HackclubRequest.resolve_channel(@id) %Q{<a href="https://hackclub.slack.com/archives/#{@id}" class="hackclub-mention hackclub-channel" target="_blank">##{display_name}</a>} end end |