Class: ApplicationComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/application_component.rb

Overview

Base component class for all ViewComponents
Provides convenient access to common helpers without needing the helpers. prefix.

== Block-Capturing Helpers Warning

IMPORTANT: Do NOT delegate helpers that accept blocks (link_to, content_tag, tag, form_with, etc.)

When you delegate a block-accepting helper, it routes through the helpers proxy which breaks
ViewComponent's block capture mechanism. This causes symptoms like:

  • Block content rendering BEFORE the wrapper element
  • Raw HTML tags (, ) appearing as visible text
  • Escaped HTML inside elements

== Solution for Components Using Block Helpers

Components that need link_to, content_tag, tag, or other block-accepting helpers
must include the ActionView helper modules directly:

class MyComponent < ApplicationComponent
include ActionView::Helpers::TagHelper
include ActionView::Helpers::UrlHelper
# ... now link_to with blocks works correctly
end

== References

Direct Known Subclasses

Crm::ActivityCardComponent, Crm::ContactCardComponent, Crm::ContentLinkEditorComponent, Crm::DailyFocusSummaryComponent, Crm::DailyFocusWidgetComponent, Crm::OppFunnelWidgetComponent, Crm::PostSeoPanelComponent, Crm::QuickSearchResultCardComponent, Crm::RevenueWidgetComponent, Crm::SeoDashboardComponent, Crm::StickyHeaderComponent, Crm::StickyHeaderComponent::NavItem, PartyAvatarComponent, SocialShareComponent, Www::AddToCartButtonComponent, Www::AssociationsSliderComponent, Www::BenefitsListComponent, Www::BlogFaqItemComponent, Www::BlogFaqSectionComponent, Www::BlogPostCardComponent, Www::BlogProductEmbedComponent, Www::CardGridComponent, Www::CarouselSliderComponent, Www::DesktopMenuComponent, Www::DocumentCardComponent, Www::FaqItemComponent, Www::FaqListComponent, Www::FeatureListComponent, Www::FloorCompatibilityTableComponent, Www::FloorHeatingCalculatorComponent, Www::FloorplanCategoryComponent, Www::FullWidthLandingPageHeaderComponent, Www::HomepageProductsComponent, Www::LandingPageCompareComponent, Www::LandingPageCtaLinkComponent, Www::LeadFormModalComponent, Www::MagazineBlogCardComponent, Www::MobileMenuComponent, Www::NavbarMenuComponent, Www::ProductCardComponent, Www::ProductCardsComponent, Www::ProductCategoryCardsComponent, Www::ProductCompareTableComponent, Www::ProductShowcaseComponent, Www::PublicationCardComponent, Www::RadiantPanelFiltersComponent, Www::RequestSmartplanSectionComponent, Www::ReviewsIo::ProductRatingComponent, Www::ReviewsIo::RatingBarComponent, Www::ReviewsIo::ReviewListComponent, Www::ReviewsIo::ReviewSliderComponent, Www::SaleBadgeComponent, Www::SectionHeaderComponent, Www::SectionNavComponent, Www::ShowcaseGridComponent, Www::SnowMeltingCalculatorComponent, Www::SnowMeltingQuoteFormComponent, Www::SupportPageHeaderComponent, Www::SupportPublicationsComponent, Www::SupportSpecificationsComponent, Www::TowelWarmerConnectionOptionsComponent, Www::TowelWarmerFiltersComponent, Www::TrainingCardComponent, Www::VideoSectionComponent

Delegated Instance Attributes collapse

Instance Method Summary collapse

Instance Method Details

Alias for Helpers#cms_link

Returns:

  • (Object)

    Helpers#cms_link

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#fetch_or_fallback(argument, constant, fallback) ⇒ Object (protected)

Utility method for validating arguments against allowed values with fallback
Ported from Railsboot::Component for compatibility



48
49
50
51
52
53
54
# File 'app/components/application_component.rb', line 48

def fetch_or_fallback(argument, constant, fallback)
  if argument.present? && constant.include?(argument.to_s)
    argument
  else
    fallback
  end
end

#image_asset_tagObject

Alias for Helpers#image_asset_tag

Returns:

  • (Object)

    Helpers#image_asset_tag

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#image_tagObject

Alias for Helpers#image_tag

Returns:

  • (Object)

    Helpers#image_tag

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#number_to_currencyObject

Alias for Helpers#number_to_currency

Returns:

  • (Object)

    Helpers#number_to_currency

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#number_with_delimiterObject

Alias for Helpers#number_with_delimiter

Returns:

  • (Object)

    Helpers#number_with_delimiter

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#post_pathObject

Alias for Helpers#post_path

Returns:

  • (Object)

    Helpers#post_path

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#post_urlObject

Alias for Helpers#post_url

Returns:

  • (Object)

    Helpers#post_url

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers

#strip_tagsObject

Alias for Helpers#strip_tags

Returns:

  • (Object)

    Helpers#strip_tags

See Also:



39
40
41
42
# File 'app/components/application_component.rb', line 39

delegate :image_tag, :image_asset_tag,
:number_to_currency, :number_with_delimiter,
:cms_link, :post_url, :post_path, :strip_tags,
to: :helpers