Class: WNS::RubyTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll-wns/assets/ruby_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, text, tokens) ⇒ RubyTag

Returns a new instance of RubyTag.



3
4
5
6
7
# File 'lib/jekyll-wns/assets/ruby_tag.rb', line 3

def initialize(tag_name, text, tokens)
  super

  @text = text.strip!.split("|")
end

Instance Method Details

#render(context) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/jekyll-wns/assets/ruby_tag.rb', line 9

def render(context)
  base = @text[0].split("#")
  text = @text[1].split("#")
  output = "<ruby>"
  i = 0
  while i < base.length()
    output += "<span class='rb" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + "' aria-hidden='true'>#{base[i]}</span><rp>(</rp><rt" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + ">#{text[i]}</rt><rp>)</rp>"
    i += 1
  end
  output += "</ruby>"
end