Class: Jekyll::RTLifyTag

Inherits:
Liquid::Tag
  • Object
show all
Defined in:
lib/jekyll/rtlify.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, variable, tokens) ⇒ RTLifyTag

Returns a new instance of RTLifyTag.



6
7
8
9
10
11
12
13
# File 'lib/jekyll/rtlify.rb', line 6

def initialize(tag_name, variable, tokens)
  super
  if match = variable.match(/{{\s*(.*)\s*}}/)
    @variable, = match.captures
  else
    raise 'invalid variable'
  end
end

Instance Method Details

#render(context) ⇒ Object



15
16
17
18
19
20
# File 'lib/jekyll/rtlify.rb', line 15

def render(context)
  html = context.find_variable(@variable)
  tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'ul']
  tags.each { |tag| html = html.gsub(/<#{tag}/, "<#{tag} dir=\"auto\"")}
  html
end