Class: Garterbelt::Renderer
- Inherits:
-
Object
- Object
- Garterbelt::Renderer
- Defined in:
- lib/renderers/renderer.rb
Instance Attribute Summary collapse
-
#escape ⇒ Object
Returns the value of attribute escape.
- #style ⇒ Object
-
#view ⇒ Object
Returns the value of attribute view.
Instance Method Summary collapse
- #indent ⇒ Object
-
#initialize(opts) ⇒ Renderer
constructor
A new instance of Renderer.
- #level ⇒ Object
- #line_end ⇒ Object
-
#output ⇒ Object
Rendering ———————————————–.
- #output=(alt_output) ⇒ Object
- #render ⇒ Object
Constructor Details
#initialize(opts) ⇒ Renderer
Returns a new instance of Renderer.
6 7 8 9 10 |
# File 'lib/renderers/renderer.rb', line 6 def initialize(opts) self.view = opts[:view] || raise(ArgumentError, ":view required in initialization options") self.style = opts.delete(:render_style) self.escape = view._escape end |
Instance Attribute Details
#escape ⇒ Object
Returns the value of attribute escape.
3 4 5 |
# File 'lib/renderers/renderer.rb', line 3 def escape @escape end |
#style ⇒ Object
25 26 27 |
# File 'lib/renderers/renderer.rb', line 25 def style @style ||= view.render_style end |
#view ⇒ Object
Returns the value of attribute view.
3 4 5 |
# File 'lib/renderers/renderer.rb', line 3 def view @view end |
Instance Method Details
#indent ⇒ Object
29 30 31 |
# File 'lib/renderers/renderer.rb', line 29 def indent style == :minified ? "" : ' '*level*2 end |
#level ⇒ Object
21 22 23 |
# File 'lib/renderers/renderer.rb', line 21 def level view._level end |
#line_end ⇒ Object
33 34 35 |
# File 'lib/renderers/renderer.rb', line 33 def line_end style == :minified ? "" : "\n" end |
#output ⇒ Object
Rendering ———————————————–
13 14 15 |
# File 'lib/renderers/renderer.rb', line 13 def output view.output end |
#output=(alt_output) ⇒ Object
17 18 19 |
# File 'lib/renderers/renderer.rb', line 17 def output=(alt_output) view.output = alt_output end |
#render ⇒ Object
37 38 39 |
# File 'lib/renderers/renderer.rb', line 37 def render raise NotImplementedError, "Subclasses must implement #render" end |