Module: Munge::Helper::Livereload

Defined in:
lib/munge/helper/livereload.rb

Instance Method Summary collapse

Instance Method Details

#livereload_script(force: false) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/munge/helper/livereload.rb', line 4

def livereload_script(force: false)
  should_show = ENV["MUNGE_ENV"] == "development" && Gem.loaded_specs.key?("reel")

  loading_script =
    %q{document.write('<script src="http://'} +
    %q{ + (location.host || 'localhost').split(':')[0]} +
    %q{ + ':35729/livereload.js?snipver=1"></'} +
    %q{ + 'script>')}

  if should_show || force
    (:script, loading_script)
  end
end