Class: Jekyll::J1LunrSearch::PageRenderer
- Inherits:
-
Object
- Object
- Jekyll::J1LunrSearch::PageRenderer
- Defined in:
- lib/starter_web/_plugins/lunr_index.rb
Instance Method Summary collapse
-
#initialize(site) ⇒ PageRenderer
constructor
A new instance of PageRenderer.
-
#prepare(item) ⇒ Object
render item, but without using its layout.
-
#render(item) ⇒ Object
render the item, parse the output and get all text elements.
Constructor Details
#initialize(site) ⇒ PageRenderer
Returns a new instance of PageRenderer.
234 235 236 |
# File 'lib/starter_web/_plugins/lunr_index.rb', line 234 def initialize(site) @site = site end |
Instance Method Details
#prepare(item) ⇒ Object
render item, but without using its layout
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/starter_web/_plugins/lunr_index.rb', line 240 def prepare(item) layout = item.data['layout'] begin item.data['layout'] = nil if item.is_a?(Jekyll::Document) output = Jekyll::Renderer.new(@site, item).run else item.render({}, @site.site_payload) output = item.output end ensure # restore original layout # item.data['layout'] = layout end output end |
#render(item) ⇒ Object
render the item, parse the output and get all text elements
262 263 264 265 |
# File 'lib/starter_web/_plugins/lunr_index.rb', line 262 def render(item) layoutless = item.dup Nokogiri::HTML(prepare(layoutless)).text end |