module Embork::Sprockets::Helpers

Public Instance Methods

asset_path(path, options = {}) click to toggle source
# File lib/embork/sprockets/helpers.rb, line 43
def asset_path(path, options = {})
  base_path = '/'
  if !options.has_key? :type
    File.join base_path, path
  else
    type = options[:type]
    case type
    when :image
      File.join base_path, 'images', path
    when :font
      File.join base_path, 'fonts', path
    when :javascript
      File.join base_path, path
    when :stylesheet
      File.join base_path, path
    else
      File.join base_path, type.to_s, path
    end
  end
end
build_version() click to toggle source
# File lib/embork/sprockets/helpers.rb, line 31
def build_version
  if self.class.use_bundled_assets
    self.class.bundle_version
  else
    nil
  end
end
javascript_embed_tag() click to toggle source
# File lib/embork/sprockets/helpers.rb, line 13
def javascript_embed_tag
end
javascript_include_tag(path) click to toggle source
# File lib/embork/sprockets/helpers.rb, line 7
def javascript_include_tag(path)
  path = self.class.use_bundled_assets ? generate_versioned_name(path) : path
  script = asset_path(path, :type => :javascript)
  %{<script src="%s"></script>} % [ script ]
end
namespace() click to toggle source
# File lib/embork/sprockets/helpers.rb, line 39
def namespace
  Embork::Sprockets::ES6ModuleTranspiler.namespace
end
stylesheet_embed_tag() click to toggle source
# File lib/embork/sprockets/helpers.rb, line 28
def stylesheet_embed_tag
end

Protected Instance Methods

generate_versioned_name(path_to_file) click to toggle source
# File lib/embork/sprockets/helpers.rb, line 66
def generate_versioned_name(path_to_file)
  ext = File.extname path_to_file
  base = File.basename path_to_file, ext
  path = File.dirname path_to_file
  path = nil if path == '.'

  versioned_name = "%s-%s%s" % [ base, self.class.bundle_version, ext ]
  (path.nil?) ? versioned_name : File.join(path, versioned_name)
end