Module: Leftovers::Precompilers::Haml
- Defined in:
- lib/leftovers/precompilers/haml.rb
Constant Summary collapse
- HAML_RUNTIME_ERROR_RE =
%r{ \A _buf\s=\s'' # preamble [\s;]* # https://github.com/haml/haml/blob/main/lib/haml/compiler.rb#L93 raise\s(?:::)?(?<class>.*)\.new\(%q\[(?<message>.*)\],\s(?<line>\d)+\) [\s;]* _buf # postamble \z }x.freeze
Class Method Summary collapse
Class Method Details
.precompile(haml) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/leftovers/precompilers/haml.rb', line 19 def self.precompile(haml) out = ::Haml::TempleEngine.new.compile(haml) if (e = out.match(HAML_RUNTIME_ERROR_RE)) raise PrecompileError.new(e[:message], line: e[:line], display_class: e[:class]) end out # :nocov: # this is for haml < 6 rescue ::Haml::Error => e raise PrecompileError.new(e., line: e.line) # :nocov: end |