Class: Ruhl::Engine
- Inherits:
-
Object
- Object
- Ruhl::Engine
- Defined in:
- lib/ruhl/rails.rb,
lib/ruhl/engine.rb,
lib/ruhl/sinatra.rb
Instance Attribute Summary collapse
-
#block_object ⇒ Object
readonly
Returns the value of attribute block_object.
-
#call_result ⇒ Object
readonly
Returns the value of attribute call_result.
-
#current_tag ⇒ Object
readonly
Returns the value of attribute current_tag.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#layout ⇒ Object
readonly
Returns the value of attribute layout.
-
#layout_source ⇒ Object
readonly
Returns the value of attribute layout_source.
-
#local_object ⇒ Object
readonly
Returns the value of attribute local_object.
-
#original_tag ⇒ Object
readonly
Returns the value of attribute original_tag.
-
#ruhl_actions ⇒ Object
readonly
Returns the value of attribute ruhl_actions.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#_render_ ⇒ Object
The render method is used within a layout to inject the results of the template render.
-
#initialize(html, options = {}) ⇒ Engine
constructor
A new instance of Engine.
- #render(current_scope) ⇒ Object
Constructor Details
#initialize(html, options = {}) ⇒ Engine
Returns a new instance of Engine.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruhl/engine.rb', line 6 def initialize(html, = {}) @local_object = [:local_object] || [:object] @block_object = [:block_object] @layout = [:layout] @layout_source = [:layout_source] if @layout || @local_object || @block_object @document = Nokogiri::HTML.fragment(html) else @document = Nokogiri::HTML(html) @document.encoding = Ruhl.encoding end end |
Instance Attribute Details
#block_object ⇒ Object (readonly)
Returns the value of attribute block_object.
3 4 5 |
# File 'lib/ruhl/engine.rb', line 3 def block_object @block_object end |
#call_result ⇒ Object (readonly)
Returns the value of attribute call_result.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def call_result @call_result end |
#current_tag ⇒ Object (readonly)
Returns the value of attribute current_tag.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def current_tag @current_tag end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def document @document end |
#layout ⇒ Object (readonly)
Returns the value of attribute layout.
3 4 5 |
# File 'lib/ruhl/engine.rb', line 3 def layout @layout end |
#layout_source ⇒ Object (readonly)
Returns the value of attribute layout_source.
3 4 5 |
# File 'lib/ruhl/engine.rb', line 3 def layout_source @layout_source end |
#local_object ⇒ Object (readonly)
Returns the value of attribute local_object.
3 4 5 |
# File 'lib/ruhl/engine.rb', line 3 def local_object @local_object end |
#original_tag ⇒ Object (readonly)
Returns the value of attribute original_tag.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def original_tag @original_tag end |
#ruhl_actions ⇒ Object (readonly)
Returns the value of attribute ruhl_actions.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def ruhl_actions @ruhl_actions end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
4 5 6 |
# File 'lib/ruhl/engine.rb', line 4 def scope @scope end |
Instance Method Details
#_render_ ⇒ Object
The render method is used within a layout to inject the results of the template render.
Ruhl::Engine.new(html, :layout => path_to_layout).render(self)
38 39 40 |
# File 'lib/ruhl/engine.rb', line 38 def _render_ document.to_s end |
#render(current_scope) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/ruhl/engine.rb', line 22 def render(current_scope) set_scope(current_scope) parse_doc(document) if @layout render_with_layout else document.to_s.gsub(/\302\240/, ' ') end end |