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



56
57
58
# File 'lib/ably_ui/core/core.rb', line 56

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



64
65
66
# File 'lib/ably_ui/core/core.rb', line 64

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