Class: Jekyll::J1LunrSearch::PageRenderer
- Inherits:
-
Object
- Object
- Jekyll::J1LunrSearch::PageRenderer
- Defined in:
- lib/starter_web/_plugins/index/lunr.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.
263 264 265 |
# File 'lib/starter_web/_plugins/index/lunr.rb', line 263 def initialize(site) @site = site end |
Instance Method Details
#prepare(item) ⇒ Object
render item, but without using its layout
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/starter_web/_plugins/index/lunr.rb', line 269 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
291 292 293 294 |
# File 'lib/starter_web/_plugins/index/lunr.rb', line 291 def render(item) layoutless = item.dup Nokogiri::HTML(prepare(layoutless)).text end |