Class: FAQML::DetailsFilter

Inherits:
Temple::Filter
  • Object
show all
Includes:
Temple::Mixins::Options
Defined in:
lib/fml/details_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DetailsFilter

Returns a new instance of DetailsFilter.



6
7
8
# File 'lib/fml/details_filter.rb', line 6

def initialize(options = {})
  super(options)
end

Instance Method Details

#call(exp) ⇒ Object



10
11
12
# File 'lib/fml/details_filter.rb', line 10

def call(exp)
  compile(exp)
end

#on_fml_qna(question, answer = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fml/details_filter.rb', line 14

def on_fml_qna(question, answer=nil)
  answer_sexp = !answer.nil? && answer.length >= 4 ? build_fml_details('answer', true, answer[2], answer[3]) : nil
  question_sexp = build_fml_details('question', false, summary = question[2], question[3])
  question_sexp.last << answer_sexp unless answer_sexp.nil?

  attrs = [:html, :attrs, [:html, :attr, 'class', [:static, 'qna']]]
  id = convert_to_id(summary.last.first)
  attrs << [:html, :attr, 'id', [:static, id]] unless id == ''
  [:html, :tag, 'section', attrs,
    question_sexp
  ]
end