Class: DocsUI::Icon
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- DocsUI::Icon
- Defined in:
- app/components/docs_ui/icon.rb
Overview
Constant Summary collapse
- MISSING_ICON =
"circle-question-mark"
Instance Method Summary collapse
-
#initialize(name, **attributes) ⇒ Icon
constructor
A new instance of Icon.
- #view_template ⇒ Object
Constructor Details
#initialize(name, **attributes) ⇒ Icon
Returns a new instance of Icon.
13 14 15 16 |
# File 'app/components/docs_ui/icon.rb', line 13 def initialize(name, **attributes) @name = name @attributes = attributes end |
Instance Method Details
#view_template ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/components/docs_ui/icon.rb', line 18 def view_template # rails_icons is a Railtie gem; outside a Rails host (isolated Phlex tests) # it isn't loaded, and in a not-yet-fully-set-up app its default library may # be unconfigured. Either way, render nothing rather than take down the page # — icons are chrome, not content. In development we still raise so a real # misconfiguration is visible. return unless defined?(::Icons::Icon) && rails_icons_library svg = svg_for(@name, **@attributes) raw(safe(svg)) if svg end |