class Tumblargh::Renderer::Base

Attributes

config[R]
context[RW]
node[R]
options[R]

Public Class Methods

contextual_tag(name, attribute=nil) click to toggle source

Define a simple tag on the block. Name being tag name, and optionally the attibute/method to call on the context. If the second argument is left off, it'll just use the tag name.

# File lib/tumblargh/renderer/base.rb, line 10
def contextual_tag(name, attribute=nil)
  class_eval do
    define_method name do
      context.send(attribute || name)
    end
  end
end
new(node, context, options = {}) click to toggle source
# File lib/tumblargh/renderer/base.rb, line 25
def initialize(node, context, options = {})
  @node = node
  @context = context
  @options = options.with_indifferent_access
end

Public Instance Methods

context_post() click to toggle source
# File lib/tumblargh/renderer/base.rb, line 31
def context_post
  real_post = context
  while not real_post.is_a?(::Tumblargh::Resource::Post)
    real_post = real_post.context
  end

  real_post
end
escape_html(str) click to toggle source
# File lib/tumblargh/renderer/base.rb, line 40
def escape_html(str)
  CGI.escapeHTML(str)
end
escape_url(url) click to toggle source
# File lib/tumblargh/renderer/base.rb, line 44
def escape_url(url)
  CGI.escape(url)
end
method_missing(method, *arguments) click to toggle source
# File lib/tumblargh/renderer/base.rb, line 57
def method_missing(method, *arguments)
  raise "Can't find anything to do with '#{method}'" if context.nil?
  context.send(method, *arguments)
end
render() click to toggle source
# File lib/tumblargh/renderer/base.rb, line 52
def render
end
Also aliased as: to_s
strip_html(str) click to toggle source
# File lib/tumblargh/renderer/base.rb, line 48
def strip_html(str)
  str.gsub(/<\/?[^>]*>/, '')
end
to_s()
Alias for: render