class Moft::GistTag

Public Instance Methods

render(context) click to toggle source
# File lib/moft/tags/gist.rb, line 9
def render(context)
  if tag_contents = @markup.strip.match(/\A(\d+) ?(\S*)\Z/)
    gist_id, filename = tag_contents[1].strip, tag_contents[2].strip
    gist_script_tag(gist_id, filename)
  else
    "Error parsing gist id"
  end
end

Private Instance Methods

gist_script_tag(gist_id, filename=nil) click to toggle source
# File lib/moft/tags/gist.rb, line 20
def gist_script_tag(gist_id, filename=nil)
  if filename.empty?
    "<script src=\"https://gist.github.com/#{gist_id}.js\"> </script>"
  else
    "<script src=\"https://gist.github.com/#{gist_id}.js?file=#{filename}\"> </script>"
  end
end