Class: Vident::Phlex::HTML
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- Vident::Phlex::HTML
- Includes:
- Component
- Defined in:
- lib/vident/phlex/html.rb
Constant Summary collapse
- STANDARD_ELEMENTS =
[:a, :abbr, :address, :article, :aside, :b, :bdi, :bdo, :blockquote, :body, :button, :caption, :cite, :code, :colgroup, :data, :datalist, :dd, :del, :details, :dfn, :dialog, :div, :dl, :dt, :em, :fieldset, :figcaption, :figure, :footer, :form, :g, :h1, :h2, :h3, :h4, :h5, :h6, :head, :header, :hgroup, :html, :i, :iframe, :ins, :kbd, :label, :legend, :li, :main, :map, :mark, :menuitem, :meter, :nav, :noscript, :object, :ol, :optgroup, :option, :output, :p, :path, :picture, :pre, :progress, :q, :rp, :rt, :ruby, :s, :samp, :script, :section, :select, :slot, :small, :span, :strong, :style, :sub, :summary, :sup, :svg, :table, :tbody, :td, :template_tag, :textarea, :tfoot, :th, :thead, :time, :title, :tr, :u, :ul, :video, :wbr].freeze
- VOID_ELEMENTS =
[:area, :br, :embed, :hr, :img, :input, :link, :meta, :param, :source, :track, :col].freeze
- VALID_TAGS =
Set[*(STANDARD_ELEMENTS + VOID_ELEMENTS)].freeze
Class Attribute Summary collapse
-
.component_source_file_path ⇒ Object
Returns the value of attribute component_source_file_path.
Class Method Summary collapse
-
.cache_component_modified_time ⇒ Object
Caching support.
- .inherited(subclass) ⇒ Object
Instance Method Summary collapse
-
#root_element(**overrides, &block) ⇒ Object
Helper to create the main element.
Class Attribute Details
.component_source_file_path ⇒ Object
Returns the value of attribute component_source_file_path.
18 19 20 |
# File 'lib/vident/phlex/html.rb', line 18 def component_source_file_path @component_source_file_path end |
Class Method Details
.cache_component_modified_time ⇒ Object
Caching support
21 22 23 24 25 |
# File 'lib/vident/phlex/html.rb', line 21 def cache_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
13 14 15 16 |
# File 'lib/vident/phlex/html.rb', line 13 def inherited(subclass) subclass.component_source_file_path = caller_locations(1, 10).reject { |l| l.label == "inherited" }[0].path super end |
Instance Method Details
#root_element(**overrides, &block) ⇒ Object
Helper to create the main element
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vident/phlex/html.rb', line 29 def root_element(**overrides, &block) tag_type = root_element_tag_type check_valid_html_tag!(tag_type) # Evaluate before generating the outer tag options to ensure DSL methods are executed if block_given? content = capture(self, &block).html_safe = resolve_root_element_attributes_before_render(overrides) if content send(tag_type, **) { content } else send(tag_type, **) end else send(tag_type, **resolve_root_element_attributes_before_render(overrides)) end end |