Class: Banzai::Filter::SuggestionFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Defined in:
lib/banzai/filter/suggestion_filter.rb

Constant Summary collapse

TAG_CLASS =

Class used for tagging elements that should be rendered

'js-render-suggestion'

Instance Method Summary collapse

Instance Method Details

#callObject


10
11
12
13
14
15
16
17
18
# File 'lib/banzai/filter/suggestion_filter.rb', line 10

def call
  return doc unless suggestions_filter_enabled?

  doc.search('pre.suggestion > code').each do |node|
    node.add_class(TAG_CLASS)
  end

  doc
end

#suggestions_filter_enabled?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/banzai/filter/suggestion_filter.rb', line 20

def suggestions_filter_enabled?
  context[:suggestions_filter_enabled]
end