Module: HamlI18nLint::Linter::CompilerExtension

Included in:
HamlI18nLint::Linter5::CompilerExtension
Defined in:
lib/haml_i18n_lint/linter/compiler_extension.rb

Instance Method Summary collapse

Instance Method Details

#compile_plainObject



12
13
14
15
16
# File 'lib/haml_i18n_lint/linter/compiler_extension.rb', line 12

def compile_plain
  super
  text = @node.value[:text]
  lint_add(text) if lint_config.need_i18n?(text)
end

#compile_scriptObject



7
8
9
10
# File 'lib/haml_i18n_lint/linter/compiler_extension.rb', line 7

def compile_script
  super
  lint_script(@node.value[:text])
end

#compile_tagObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/haml_i18n_lint/linter/compiler_extension.rb', line 28

def compile_tag
  super
  if @node.value[:parse]
    lint_script(@node.value[:value])
  else
    value = @node.value[:value]
    lint_add(value) if lint_config.need_i18n?(value)
  end

  placeholder = @node.value.dig(:attributes, 'placeholder') || ""
  lint_add(placeholder) if lint_config.need_i18n?(placeholder)

  value = @node.value.dig(:attributes, 'value') || ""
  lint_add(value) if lint_config.need_i18n?(value)

  lint_attributes
end

#lint_attributesObject



22
23
24
25
26
# File 'lib/haml_i18n_lint/linter/compiler_extension.rb', line 22

def lint_attributes
  lint_attributes_hashes.any? do |attributes_hash|
    lint_script("{#{attributes_hash}}")
  end
end

#lint_attributes_hashesObject



18
19
20
# File 'lib/haml_i18n_lint/linter/compiler_extension.rb', line 18

def lint_attributes_hashes
  @node.value[:attributes_hashes]
end