Class: Bridgetown::Converters::SerbeaTemplates
- Inherits:
-
Bridgetown::Converter
- Object
- Plugin
- Bridgetown::Converter
- Bridgetown::Converters::SerbeaTemplates
- Defined in:
- lib/bridgetown-core/converters/serbea_templates.rb
Instance Method Summary collapse
-
#convert(content, convertible) ⇒ String
Logic to do the Serbea content conversion.
- #matches(ext, convertible) ⇒ Object
- #output_ext(ext) ⇒ Object
Methods inherited from Bridgetown::Converter
#initialize, input, #inspect, #line_start, support_slots, supports_slots?
Methods inherited from Plugin
Methods included from Prioritizable
Constructor Details
This class inherits a constructor from Bridgetown::Converter
Instance Method Details
#convert(content, convertible) ⇒ String
Logic to do the Serbea content conversion.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bridgetown-core/converters/serbea_templates.rb', line 31 def convert(content, convertible) return content if convertible.data[:template_engine].to_s != "serbea" serb_view = Bridgetown::SerbeaView.new(convertible) serb_renderer = Tilt::SerbeaTemplate.new(convertible.path) { content } if convertible.is_a?(Bridgetown::Layout) serb_renderer.render(serb_view) do convertible.current_document_output end else serb_renderer.render(serb_view) end end |
#matches(ext, convertible) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bridgetown-core/converters/serbea_templates.rb', line 47 def matches(ext, convertible) if convertible.data[:template_engine].to_s == "serbea" || (convertible.data[:template_engine].nil? && @config[:template_engine].to_s == "serbea") convertible.data[:template_engine] = "serbea" return true end super(ext).tap do |ext_matches| convertible.data[:template_engine] = "serbea" if ext_matches end end |
#output_ext(ext) ⇒ Object
60 61 62 |
# File 'lib/bridgetown-core/converters/serbea_templates.rb', line 60 def output_ext(ext) ext == ".serb" ? ".html" : ext end |