Class: HamlI18nLint::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/haml_i18n_lint/linter.rb,
lib/haml_i18n_lint/linter/compiler_extension.rb

Overview

Linter linting a Haml template

Direct Known Subclasses

Linter5

Defined Under Namespace

Modules: CompilerExtension Classes: AttributesParseError, Result, ResultSet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Lint

Returns new linter with given configuration.

Parameters:

  • config (Config)

    the configuration



50
51
52
# File 'lib/haml_i18n_lint/linter.rb', line 50

def initialize(config)
  @config = config
end

Instance Attribute Details

#filenameString (readonly)

Returns name of the linted file.

Returns:

  • (String)

    name of the linted file



# File 'lib/haml_i18n_lint/linter.rb', line 11


#nodeHaml::Parser::ParseNode (readonly)

Returns the node that needs i18n.

Returns:

  • (Haml::Parser::ParseNode)

    the node that needs i18n.



# File 'lib/haml_i18n_lint/linter.rb', line 14


#textString (readonly)

Returns the text that needs i18n.

Returns:

  • (String)

    the text that needs i18n.



# File 'lib/haml_i18n_lint/linter.rb', line 17


Instance Method Details

#lint(filename:, template:) ⇒ Linter::ResultSet

Linting given template

Parameters:

  • filename (String)

    the filename

  • template (String)

    the Haml template

Returns:

Raises:



60
61
62
63
64
65
# File 'lib/haml_i18n_lint/linter.rb', line 60

def lint(filename:, template:)
  haml_options = ::Haml::Options.new
  haml_options[:filename] = filename
  node = parse(haml_options, template)
  compiler(haml_options).compile(node)
end