Class: Rayo::TagContext
- Inherits:
-
Radius::Context
- Object
- Radius::Context
- Rayo::TagContext
- Defined in:
- lib/rayo/tag_context.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
Instance Method Summary collapse
- #error(text) ⇒ Object
-
#initialize(page) ⇒ TagContext
constructor
A new instance of TagContext.
- #render_tag(name, attributes = {}, &block) ⇒ Object
- #tag_missing(name, attributes = {}, &block) ⇒ Object
- #with_format(format) ⇒ Object
Constructor Details
#initialize(page) ⇒ TagContext
Returns a new instance of TagContext.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rayo/tag_context.rb', line 5 def initialize(page) super() @page = page globals.page = @page globals.storage = @page.storage globals.config = @page.storage.config tagger = @page.storage.config.create_tagger tagger.methods.each do |name| define_tag(name[4..-1]) { |tag_binding| tagger.send name, tag_binding } if name[0..3] == 'tag:' end end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/rayo/tag_context.rb', line 3 def page @page end |
Instance Method Details
#error(text) ⇒ Object
32 33 34 |
# File 'lib/rayo/tag_context.rb', line 32 def error( text ) "<strong class=\"error\">#{text}</strong>" end |
#render_tag(name, attributes = {}, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/rayo/tag_context.rb', line 20 def render_tag(name, attributes = {}, &block) super rescue Exception => e error("#{e.} <pre>#{e.backtrace.join("\n")}</pre>") end |
#tag_missing(name, attributes = {}, &block) ⇒ Object
26 27 28 29 30 |
# File 'lib/rayo/tag_context.rb', line 26 def tag_missing(name, attributes = {}, &block) super rescue Radius::UndefinedTagError => e error("#{e.} <pre>#{e.backtrace.join("\n")}</pre>") end |
#with_format(format) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rayo/tag_context.rb', line 36 def with_format( format ) old_format = globals.format globals.format = format result = yield globals.format = old_format result end |