Sha256: 620de0cbda78e29192e7fa81986bea666361e5544379305f49bc29df291c2fb5
Contents?: true
Size: 993 Bytes
Versions: 81
Compression:
Stored size: 993 Bytes
Contents
class PageContext < Radius::Context attr_reader :page def initialize(page) super @page = page globals.page = @page page.tags.each do |name| define_tag(name) { |tag_binding| page.render_tag(name, tag_binding) } end end def dup rv = self.class.new(page) rv.globals = globals.dup rv.definitions = definitions.dup rv end def render_tag(name, attributes = {}, &block) binding = @tag_binding_stack.last locals = binding ? binding.locals : globals set_process_variables(locals.page) super rescue Exception => e raise e if raise_errors? @tag_binding_stack.pop unless @tag_binding_stack.last == binding render_error_message(e.message) end private def render_error_message(message) "<div><strong>#{message}</strong></div>" end def set_process_variables(page) page.request ||= @page.request page.response ||= @page.response end def raise_errors? Rails.env != 'production' end end
Version data entries
81 entries across 81 versions & 1 rubygems