5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/easy_poller/helper.rb', line 5
def easy_poller(url, poll: true, interval: 3000, **html_options)
klasses = (html_options.delete(:class) || '').split.unshift('easy_poller').join(' ')
parsed_html_opts = ''
html_options.each do |key, array|
parsed_html_opts << " #{key}=\"#{array}\""
end
parsed_html_opts.rstrip!
replace = {
html_options: parsed_html_opts,
klasses: ERB::Util.html_escape(klasses),
poll: ERB::Util.html_escape(poll),
url: ERB::Util.html_escape(url),
interval: ERB::Util.html_escape(interval)
}
html = %(<div%{html_options} class="%{klasses}" data-poll="%{poll}" data-interval="%{interval}" data-url="%{url}"></div>) % replace
html.respond_to?(:html_safe) ? html.html_safe : html
end
|