Class: Webpack::ViewHelpers::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/webpack/view_helpers.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ Context

Returns a new instance of Context.



33
34
35
# File 'lib/webpack/view_helpers.rb', line 33

def initialize(view_context)
  @view_context = view_context
end

Instance Attribute Details

#view_contextObject (readonly)

Returns the value of attribute view_context.



31
32
33
# File 'lib/webpack/view_helpers.rb', line 31

def view_context
  @view_context
end

Instance Method Details

#entry_url(name, ext) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/webpack/view_helpers.rb', line 37

def entry_url(name, ext)
  if Webpack.config.use_server
    server_url("#{name}.#{ext}")
  else
    Webpack.fetch_entry(name.to_s, ext.to_s)
  end
end

#static_file_url(path) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/webpack/view_helpers.rb', line 45

def static_file_url(path)
  if Webpack.config.use_server
    server_url(path)
  else
    static_file = Webpack.fetch_static_file("#{Webpack.config.static_path}/#{path}")
    if Webpack.config.cdn_host.present?
      "#{protocol}#{Webpack.config.cdn_host}#{static_file}"
    else
      static_file
    end
  end
end