Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HTML elements #631

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/phlex/elements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def registered_elements
# @note The methods defined by this macro depend on other methods from {SGML} so they should always be mixed into an {HTML} or {SVG} component.
# @example Register the custom element `<trix-editor>`
# register_element :trix_editor
def register_element(method_name, tag: nil)
def register_element(method_name, tag: nil, deprecated: false)
tag ||= method_name.name.tr("_", "-")

class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
Expand Down Expand Up @@ -73,7 +73,7 @@ def #{method_name}(**attributes, &block)
end

# @api private
def register_void_element(method_name, tag: method_name.name.tr("_", "-"))
def register_void_element(method_name, tag: method_name.name.tr("_", "-"), deprecated: false)
class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
# frozen_string_literal: true

Expand Down
44 changes: 43 additions & 1 deletion lib/phlex/html/standard_elements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,27 @@ module Phlex::HTML::StandardElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/aside
register_element :aside, tag: "aside"

# @!method audio(**attributes, &content)
# Outputs an `<audio>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
register_element :audio, tag: "audio"

# @!method b(**attributes, &content)
# Outputs a `<b>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/b
register_element :b, tag: "b"

# @!method base(**attributes, &content)
# Outputs a `<base>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
register_element :base, tag: "base"

# @!method bdi(**attributes, &content)
# Outputs a `<bdi>` tag.
# @return [nil]
Expand Down Expand Up @@ -368,6 +382,13 @@ module Phlex::HTML::StandardElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/mark
register_element :mark, tag: "mark"

# @!method menu(**attributes, &content)
# Outputs a `<menu>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menu
register_element :menu, tag: "menu"

# @!method meter(**attributes, &content)
# Outputs a `<meter>` tag.
# @return [nil]
Expand Down Expand Up @@ -438,6 +459,13 @@ module Phlex::HTML::StandardElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/picture
register_element :picture, tag: "picture"

# @!method portal(**attributes, &content)
# Outputs a `<portal>` tag. (Experimental)
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/portal
register_element :portal, tag: "portal"

# @!method pre(**attributes, &content)
# Outputs a `<pre>` tag.
# @return [nil]
Expand Down Expand Up @@ -474,7 +502,7 @@ module Phlex::HTML::StandardElements
register_element :rt, tag: "rt"

# @!method ruby(**attributes, &content)
# Outputs a `<ruby>` tag.
# Outputs a `<ruby>` tag. (The best tag ever!)
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/ruby
Expand All @@ -501,6 +529,13 @@ module Phlex::HTML::StandardElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/script
register_element :script, tag: "script"

# @!method search(**attributes, &content)
# Outputs a `<search>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/search
register_element :search, tag: "search"

# @!method section(**attributes, &content)
# Outputs a `<section>` tag.
# @return [nil]
Expand Down Expand Up @@ -669,6 +704,13 @@ module Phlex::HTML::StandardElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/ul
register_element :ul, tag: "ul"

# @!method var(**attributes, &content)
# Outputs a `<var>` tag.
# @return [nil]
# @yieldparam component [self]
# @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/var
register_element :var, tag: "var"

# @!method video(**attributes, &content)
# Outputs a `<video>` tag.
# @return [nil]
Expand Down
14 changes: 7 additions & 7 deletions lib/phlex/html/void_elements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ module Phlex::HTML::VoidElements
# @see https://developer.mozilla.org/docs/Web/HTML/Element/br
register_void_element :br, tag: "br"

# @!method col(**attributes, &content)
# Outputs a `<col>` tag.
# @return [nil]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/col
register_void_element :col, tag: "col"

# @!method embed(**attributes, &content)
# Outputs an `<embed>` tag.
# @return [nil]
Expand Down Expand Up @@ -56,7 +62,7 @@ module Phlex::HTML::VoidElements
# Outputs a `<param>` tag.
# @return [nil]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/param
register_void_element :param, tag: "param"
register_void_element :param, tag: "param", deprecated: true

# @!method source(**attributes, &content)
# Outputs a `<source>` tag.
Expand All @@ -69,10 +75,4 @@ module Phlex::HTML::VoidElements
# @return [nil]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/track
register_void_element :track, tag: "track"

# @!method col(**attributes, &content)
# Outputs a `<col>` tag.
# @return [nil]
# @see https://developer.mozilla.org/docs/Web/HTML/Element/col
register_void_element :col, tag: "col"
end