Class: SearchTag

Inherits:
LiquidumBlock
  • Object
show all
Defined in:
lib/scribo/liquid/tags/search_tag.rb

Overview

Full-text searches content, in both content and properties

Basic usage:

{%search q%}
{{search|size}} results
{%endsearch%}

Note: It will only look at published content

Instance Method Summary collapse

Instance Method Details

#render(context) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scribo/liquid/tags/search_tag.rb', line 12

def render(context)
  super

  current_content = context.registers['content']
  request = context.registers['controller'].request

  contents = current_content.site.contents.published.search(request.params[argv1])

  result = ''
  context.stack do
    context['results'] = contents.map { |content| Scribo::ContentDrop.new(content) }
    result += render_body
  end
  result
end