class Jekyll::RTLifyTag

Public Class Methods

new(tag_name, variable, tokens) click to toggle source
Calls superclass method
# File lib/jekyll/rtlify.rb, line 5
def initialize(tag_name, variable, tokens)
  super
  if match = variable.match(/{{\s*(.*)\s*}}/)
    @variable, = match.captures
  else
    raise 'invalid variable'
  end
end

Public Instance Methods

render(context) click to toggle source
# File lib/jekyll/rtlify.rb, line 14
def render(context)
  html = context.find_variable(@variable)
  tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'ul', 'ol']
  tags.each { |tag| html = html.gsub(/<#{tag}\s/, "<#{tag} dir=\"auto\" ")}
  tags.each { |tag| html = html.gsub(/<#{tag}>/, "<#{tag} dir=\"auto\">")}
  html
end