Class: Rack::Rekon::ResponseRewriters::SammyTemplate
- Inherits:
-
Object
- Object
- Rack::Rekon::ResponseRewriters::SammyTemplate
- Defined in:
- lib/rack/rekon/response_rewriters/sammy_template.rb
Instance Attribute Summary collapse
-
#app_root ⇒ Object
readonly
Returns the value of attribute app_root.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(app_root, body) ⇒ SammyTemplate
constructor
A new instance of SammyTemplate.
- #rewritten_body ⇒ Object
Constructor Details
#initialize(app_root, body) ⇒ SammyTemplate
Returns a new instance of SammyTemplate.
8 9 10 |
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 8 def initialize(app_root, body) @app_root, @body = app_root, body end |
Instance Attribute Details
#app_root ⇒ Object (readonly)
Returns the value of attribute app_root.
7 8 9 |
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 7 def app_root @app_root end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 7 def body @body end |
Instance Method Details
#doc ⇒ Object
12 13 14 |
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 12 def doc @doc ||= Nokogiri::HTML::DocumentFragment.parse(body) end |
#rewritten_body ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 16 def rewritten_body return body if ejs? ensure_rewritten! doc.to_html end |