module Leftovers::Haml

Public Instance Methods

precompile(file, name) click to toggle source
# File lib/leftovers/haml.rb, line 7
    def precompile(file, name)
      return '' unless Leftovers.try_require('haml', message: <<~MESSAGE) # rubocop:disable Layout/EmptyLineAfterGuardClause
        Skipped parsing #{name.relative_path}, because the haml gem was not available
        `gem install haml`
      MESSAGE

      begin
        ::Haml::Engine.new(file).precompiled
      rescue ::Haml::SyntaxError => e
        Leftovers.warn "#{e.class}: #{e.message} #{name.relative_path}:#{e.line}"
        ''
      end
    end