class Razor::Renderer

Attributes

string[R]

Public Class Methods

extension(ext) click to toggle source
# File lib/razor/renderer.rb, line 88
def extension(ext)
        Getter.define_extension(ext, self)
end
get(path, proc) click to toggle source
# File lib/razor/renderer.rb, line 62
def get(path, proc)
        Getter.new(path, proc).renderer
end
name(n) click to toggle source
# File lib/razor/renderer.rb, line 84
def name(n)
        Getter.define_renderer(n, self)
end
name_ext(n) click to toggle source
# File lib/razor/renderer.rb, line 79
def name_ext(n)
        name(n)
        extension(n)
end
new(string) click to toggle source
# File lib/razor/renderer.rb, line 95
def initialize(string)
        @string = string
end
try_load() click to toggle source
# File lib/razor/renderer.rb, line 66
def try_load
        constants.each { |constname|
                const = const_get constname
                const.is_a? Class or next
                const.ancestors.include? Renderer or next
                const.respond_to? :load or next
                begin
                        const.load
                rescue LoadError
                end
        }
end

Public Instance Methods

layout_render(context) click to toggle source
# File lib/razor/renderer.rb, line 99
def layout_render(context)
        valid? or return context['yield']
        render(context)
end
render(context) click to toggle source
# File lib/razor/renderer.rb, line 108
def render(context)
        valid? or return ''
        Mustache.render(@string, context)
end
valid?() click to toggle source
# File lib/razor/renderer.rb, line 104
def valid?
        !!@string
end