Class: Jekyll::HackclubMention
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::HackclubMention
- Defined in:
- lib/tags/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.
7 8 9 10 11 |
# File 'lib/tags/mentions.rb', line 7 def initialize(tagName, content, tokens) super @args = content.split(" ; ").map(&:strip) @id = @args[0] end |
Instance Method Details
#render(context) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tags/mentions.rb', line 13 def render(context) parts = @id.split(" | ") @id = parts[0] @pipes = parts[1..-1] if @id && @id.start_with?("U") display_name = @args[1] || HackclubRequest.resolve_username(@id) display_name = ArgsParser.eval_pipes_with_val(display_name, @pipes) %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) display_name = ArgsParser.eval_pipes_with_val(display_name, @pipes) %Q{<a href="https://hackclub.slack.com/archives/#{@id}" class="hackclub-mention hackclub-channel" target="_blank">##{display_name}</a>} elsif @id && @id.start_with?("S") display_name = @args[1] || HackclubRequest.resolve_usergroup(@id) display_name = ArgsParser.eval_pipes_with_val(display_name, @pipes) %Q{@#{display_name}} end end |