Module: Hamlit::Compilers::Attributes

Extended by:
Hamlit::Concerns::Included
Includes:
NewAttribute, OldAttribute, RuntimeAttribute
Included in:
Hamlit::Compiler
Defined in:
lib/hamlit/compilers/attributes.rb

Constant Summary

Constants included from OldAttribute

OldAttribute::BOOLEAN_ATTRIBUTES, OldAttribute::CLOSE_TOKEN_TYPES, OldAttribute::DEFAULT_COUNTS, OldAttribute::IGNORED_EXPRESSIONS, OldAttribute::JOINABLE_TOKENS, OldAttribute::JOIN_ATTRIBUTES, OldAttribute::NESTABLE_ATTRIBUTES, OldAttribute::OPEN_TOKEN_TYPES

Constants included from Hamlit::Concerns::Lexable

Hamlit::Concerns::Lexable::TYPE_POSITION

Instance Method Summary collapse

Methods included from Hamlit::Concerns::Included

extended

Methods included from RuntimeAttribute

#merge_runtime_attributes, #on_runtime

Methods included from Hamlit::Concerns::StringInterpolation

#contains_interpolation?, #string_literal

Methods included from OldAttribute

#compile_old_attribute

Methods included from Hamlit::Concerns::Lexable

#convert_position, #skip_tokens!, #type_of

Methods included from Hamlit::Concerns::Balanceable

#balanced_braces_exist?, #balanced_embexprs_exist?, #balanced_parens_exist?, #fetch_balanced_braces, #fetch_balanced_embexprs, #fetch_balanced_parentheses

Methods included from Hamlit::Concerns::AttributeBuilder

#flatten_attributes

Methods included from NewAttribute

#compile_new_attribute

Instance Method Details

#on_haml_attrs(*attrs) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/hamlit/compilers/attributes.rb', line 21

def on_haml_attrs(*attrs)
  attrs = compile_attributes(attrs)
  attrs = join_ids(attrs)
  attrs = combine_classes(attrs)
  attrs = sort_attributes(attrs)

  if has_runtime_attribute?(attrs) && has_attr?(attrs, 'class', 'id')
    attrs = merge_runtime_attributes(attrs)
    return [:html, :attrs, *escape_attribute_values(attrs)]
  end
  attrs = attrs.map { |a| compile(a) }

  [:html, :attrs, *escape_attribute_values(attrs)]
end