Class: Brut::FrontEnd::Component

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Brut::Framework::Errors, Helpers, I18n::ForHTML
Defined in:
lib/brut/front_end/component.rb

Overview

A Component is the top level class for managing the rendering of content. It is a Phlex component with additional features. Components are the primary mechanism for managing view complexity and managing markup re-use in Brut.

To create a component, subclass this class (or, more likely, your app's AppComponent) and provide an initializer that accepts keyword arguments. The names of these arguments will be used to locate the values that Brut will pass in when creating your component object.

Consult Brut's documentation on keyword injection to know what values you may use and how values are located.

Becuase this is a Phlex component, you must implement view_template and make calls to Phlex's API to create the markup for your component.

Defined Under Namespace

Modules: Helpers

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#global_component, #inline_svg

Methods included from I18n::ForHTML

#html_escape, #t

Methods included from I18n::BaseMethods

#l, #t, #t_direct, #this_field_value

Methods included from Brut::Framework::Errors

#abstract_method!, #bug!

Class Method Details

.component_nameObject

The name of this component, used for debugging and other purposes. Do not override this.



115
116
117
# File 'lib/brut/front_end/component.rb', line 115

def self.component_name = self.name
# Convenience method to get the component name. This just calls the class
# method {.component_name}.

Instance Method Details

#component_nameObject

Convenience method to get the component name. This just calls the class method component_name.



118
# File 'lib/brut/front_end/component.rb', line 118

def component_name = self.class.component_name