Class: Rack::Rekon::ResponseRewriters::SammyTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/rekon/response_rewriters/sammy_template.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_rootObject (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

#bodyObject (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

#docObject



12
13
14
# File 'lib/rack/rekon/response_rewriters/sammy_template.rb', line 12

def doc
  @doc ||= Nokogiri::HTML::DocumentFragment.parse(body)
end

#rewritten_bodyObject



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