Module: AblyUi::Core::Util
- Included in:
- Code, ContactFooter, FeatureFooter, Footer, Meganav, MeganavBlogPostsList, MeganavContentCompany, MeganavContentDevelopers, MeganavContentPlatform, MeganavContentUseCases, MeganavItemsDesktop, MeganavItemsMobile, MeganavItemsSignedIn, MeganavSearch, MeganavSearchPanel, MeganavSearchSuggestions, Showcase, SignOutLink, Uptime
- Defined in:
- lib/ably_ui/core/core.rb
Constant Summary collapse
- DEFAULT_URL_BASE =
For components which use relative links we need an option to set a base URL because they might be used on a different domain (like pages.ably.com). The below sets a default method to be used in templates but requires the definition of url_base.
''
Instance Method Summary collapse
- #abs_url(path) ⇒ Object
-
#append_random_postfix(id) ⇒ Object
This is useful where we need to use an HTML id (like in aria-controls attribute) but we know the component might be used multiple times per page so we can’t just hard code one in HTML.
Instance Method Details
#abs_url(path) ⇒ Object
64 65 66 |
# File 'lib/ably_ui/core/core.rb', line 64 def abs_url(path) "#{url_base}#{path}" end |
#append_random_postfix(id) ⇒ Object
This is useful where we need to use an HTML id (like in aria-controls attribute) but we know the component might be used multiple times per page so we can’t just hard code one in HTML. eg. my-component -> my-component-uur0cj2h credits gist.github.com/mbajur/2aba832a6df3fc31fe7a82d3109cb626
72 73 74 |
# File 'lib/ably_ui/core/core.rb', line 72 def append_random_postfix(id) "#{id}-#{rand(36**8).to_s(36)}" end |