Class: Bridgetown::Converters::SerbeaTemplates
- Inherits:
-
Bridgetown::Converter
- Object
- Plugin
- Bridgetown::Converter
- Bridgetown::Converters::SerbeaTemplates
- Defined in:
- bridgetown-core/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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'bridgetown-core/lib/bridgetown-core/converters/serbea_templates.rb', line 35 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, line_start(convertible) ) { 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
53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'bridgetown-core/lib/bridgetown-core/converters/serbea_templates.rb', line 53 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
66 67 68 |
# File 'bridgetown-core/lib/bridgetown-core/converters/serbea_templates.rb', line 66 def output_ext(ext) ext == ".serb" ? ".html" : ext end |