Class: Well::Element

Inherits:
Object
  • Object
show all
Includes:
Component
Defined in:
lib/well/element.rb

Overview

Class representing BEM element component.

Instance Attribute Summary

Attributes included from Component

#identifier

Instance Method Summary collapse

Methods included from Component

#element, #evaluate, #modified_identifier, #modifier, #other_classes, #output_buffer, #output_classes

Constructor Details

#initialize(base, tag_name, identifier, opts = {}) ⇒ Element

Returns a new instance of Element.

Parameters:

  • base (Block, Element)

    The base element used as evaluation context

  • tag_name (Symbol)

    The name of the HTML element to build

  • identifier (String)

    The main CSS class which represents the role of the BEM block

  • opts (Hash) (defaults to: {})

14
15
16
# File 'lib/well/element.rb', line 14

def initialize(base, tag_name, identifier, opts = {})
  @base, @tag_name, @identifier, @opts = base, tag_name, identifier, opts
end

Instance Method Details

#baseBlock, Element

The base evaludation context for a BEM element can be either a Block or an Well::Element.

Returns:


21
22
23
# File 'lib/well/element.rb', line 21

def base
  @base
end

#compiled_identifierString

Builds CSS class representing BEM element component.

Returns:

  • (String)

27
28
29
30
31
# File 'lib/well/element.rb', line 27

def compiled_identifier
  ids = [base.identifier]
  ids << Well.config.element_separator << identifier
  ids.join
end