Class: Trellis::Renderer
- Includes:
- Radius
- Defined in:
- lib/trellis/trellis.rb
Overview
– Renderer – Responsible for processing tags/components in the page templates Uses the Radius context object onto which components registered themselves (the tags that they respond to)
Instance Method Summary collapse
-
#initialize(page) ⇒ Renderer
constructor
A new instance of Renderer.
- #render ⇒ Object
Constructor Details
#initialize(page) ⇒ Renderer
Returns a new instance of Renderer.
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
# File 'lib/trellis/trellis.rb', line 614 def initialize(page) @page = page @context = Context.new # add all instance variables in the page as values accesible from the tags page.instance_variables.each do |var| value = page.instance_variable_get(var) unless value.kind_of?(Trellis::Page) sym = "#{var}=".split('@').last.to_sym @context.globals.send(sym, value) end end # add other useful values to the tag context @context.globals.send(:page_name=, page.class.to_s) #TODO add public page methods to the context # add the page to the context too @context.globals.page = page # register the components contained in the page with the renderer's context page.class.components.each do |component| component.register_with_tag_context(@context) end @parser = Parser.new(@context, :tag_prefix => 'trellis') end |
Instance Method Details
#render ⇒ Object
644 645 646 |
# File 'lib/trellis/trellis.rb', line 644 def render @parser.parse(@page.class.parsed_template.to_html) end |