Module: AblyUi::Core::Util

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

Instance Method Details

#abs_url(path) ⇒ Object



68
69
70
# File 'lib/ably_ui/core/core.rb', line 68

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



76
77
78
# File 'lib/ably_ui/core/core.rb', line 76

def append_random_postfix(id)
  "#{id}-#{rand(36**8).to_s(36)}"
end