Class: LinkToComponent

Inherits:
Component show all
Defined in:
app/components/link_to_component.rb

Overview

LinkTo - anchor element.

Usage:

LinkTo(href: "/about") { text "About Us" }
LinkTo(href: "/help", target: "_blank") { text "Help" }

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



15
16
17
18
19
20
21
22
# File 'app/components/link_to_component.rb', line 15

def to_s
  opts = { href: href }
  opts[:class] = css_class if css_class
  opts[:target] = target if target
  opts[:rel] = rel if rel

  tag.a(**merge_html_options(**opts)) { @content }
end