Class: Vident::Phlex::HTML

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Component
Defined in:
lib/vident/phlex/html.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.component_source_file_pathObject

Returns the value of attribute component_source_file_path.



22
23
24
# File 'lib/vident/phlex/html.rb', line 22

def component_source_file_path
  @component_source_file_path
end

Class Method Details

.attribute(name, **options) ⇒ Object

Phlex uses a DSL to define the document, and those methods could easily clash with our attribute accessors. Therefore in Phlex components we do not create attribute accessors, and instead use instance variables directly.



17
18
19
20
# File 'lib/vident/phlex/html.rb', line 17

def attribute(name, **options)
  options[:delegates] = false
  super
end

.current_component_modified_timeObject

Caching support

Raises:

  • (StandardError)


25
26
27
28
29
# File 'lib/vident/phlex/html.rb', line 25

def current_component_modified_time
  path = component_source_file_path
  raise StandardError, "No component source file exists #{path}" unless path && ::File.exist?(path)
  ::File.mtime(path).to_i.to_s
end

.inherited(subclass) ⇒ Object



9
10
11
12
# File 'lib/vident/phlex/html.rb', line 9

def inherited(subclass)
  subclass.component_source_file_path = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path
  super
end

Instance Method Details

#parent_element(**options) ⇒ Object Also known as: root

Helper to create the main element



33
34
35
# File 'lib/vident/phlex/html.rb', line 33

def parent_element(**options)
  @parent_element ||= RootComponent.new(**parent_element_attributes(options))
end