Sha256: 042d02c5c16ec77f845fe88362ffa9d184b4c42b075eded5e407e6e1fdf92e23

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

module SlimLint
  # Generates a {SlimLint::Sexp} suitable for consumption by the
  # {RubyExtractor}.
  #
  # This is mostly copied from Slim::Engine, with some filters and generators
  # omitted.
  class RubyExtractEngine < Temple::Engine
    define_options sort_attrs: true,
                   format: :xhtml,
                   attr_quote: '"',
                   merge_attrs: { 'class' => ' ' },
                   default_tag: 'div'

    filter :Encoding
    filter :RemoveBOM

    # Parse into S-expression using Slim parser
    use Slim::Parser

    # Perform additional processing so extracting Ruby code in {RubyExtractor}
    # is easier. We don't do this for regular linters because some information
    # about the original syntax tree is lost in the process, but that doesn't
    # matter in this case.
    use Slim::Embedded
    use Slim::Interpolation
    use Slim::Splat::Filter
    use Slim::DoInserter
    use Slim::EndInserter
    use Slim::Controls
    html :AttributeSorter
    html :AttributeMerger
    use Slim::CodeAttributes
    filter :ControlFlow
    filter :MultiFlattener
    filter :StaticMerger

    # Converts Array-based S-expressions into SlimLint::Sexp objects, and gives
    # them line numbers so we can easily map from the Ruby source to the
    # original source
    use SlimLint::Filters::SexpConverter
    use SlimLint::Filters::InjectLineNumbers
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slim_lint-0.3.0 lib/slim_lint/ruby_extract_engine.rb
slim_lint-0.2.0 lib/slim_lint/ruby_extract_engine.rb
slim_lint-0.1.0 lib/slim_lint/ruby_extract_engine.rb