Class: Haml2html::Converter
- Inherits:
-
Object
- Object
- Haml2html::Converter
- Defined in:
- lib/haml2html/converter.rb
Constant Summary collapse
- VOID_TAGS =
%w[area base br col embed hr img input link meta param source track wbr].freeze
- SUPPORTED_FILTERS =
%w[plain escaped javascript css erb ruby].freeze
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
Instance Method Summary collapse
-
#initialize(template, options = {}) ⇒ Converter
constructor
A new instance of Converter.
- #render ⇒ Object
Constructor Details
#initialize(template, options = {}) ⇒ Converter
Returns a new instance of Converter.
15 16 17 18 19 20 |
# File 'lib/haml2html/converter.rb', line 15 def initialize(template, = {}) @template = template.respond_to?(:read) ? template.read : template.to_s @lines = @template.lines @filename = [:filename] @diagnostics = [] end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
13 14 15 |
# File 'lib/haml2html/converter.rb', line 13 def diagnostics @diagnostics end |
Instance Method Details
#render ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/haml2html/converter.rb', line 22 def render ast = Haml::Parser.new(filename: @filename).call(@template) output = emit_children(ast.children, 0) raise ConversionError, diagnostics if diagnostics.any? output end |