Module: OpalWebpackLoader::RailsViewHelper

Defined in:
lib/opal-webpack-loader/view_helper.rb,
lib/opal-webpack-loader/rails_view_helper.rb

Instance Method Summary collapse

Instance Method Details

#owl_include_tag(path) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/opal-webpack-loader/view_helper.rb', line 3

def owl_include_tag(path)
  case Rails.env
  when 'production'
    public, packs, asset = path.split('/')
    asset_path = OpalWebpackLoader::Manifest.lookup_path_for(asset)
    "<script type=\"application/javascript\" src=\"#{asset_path}\"></script>"
  when 'development'
    "<script type=\"application/javascript\" src=\"#{'http://localhost:3035' + path[0..-4] + '_development' + path[-3..-1]}\"></script>"
  when 'test'
    real_path = path[0..-4] + '_test' + path[-3..-1]
    public, packs, asset = real_path.split('/')
    asset_path = OpalWebpackLoader::Manifest.lookup_path_for(asset)
    "<script type=\"application/javascript\" src=\"#{asset_path}\"></script>"
  end
end