Module: Embork::Sprockets::Helpers
- Defined in:
- lib/embork/sprockets/helpers.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #asset_path(path, options = {}) ⇒ Object
- #build_version ⇒ Object
- #javascript_embed_tag ⇒ Object
- #javascript_include_tag(path) ⇒ Object
- #namespace ⇒ Object
- #stylesheet_embed_tag ⇒ Object
- #stylesheet_link_tag(path, options = {}) ⇒ Object
Instance Method Details
#asset_path(path, options = {}) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/embork/sprockets/helpers.rb', line 43 def asset_path(path, = {}) base_path = '/' if !.has_key? :type File.join base_path, path else type = [: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 ⇒ Object
31 32 33 34 35 36 37 |
# 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 ⇒ Object
13 14 |
# File 'lib/embork/sprockets/helpers.rb', line 13 def end |
#javascript_include_tag(path) ⇒ Object
7 8 9 10 11 |
# 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 ⇒ Object
39 40 41 |
# File 'lib/embork/sprockets/helpers.rb', line 39 def namespace Embork::Sprockets::ES6ModuleTranspiler.namespace end |
#stylesheet_embed_tag ⇒ Object
28 29 |
# File 'lib/embork/sprockets/helpers.rb', line 28 def end |
#stylesheet_link_tag(path, options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/embork/sprockets/helpers.rb', line 16 def stylesheet_link_tag(path, = {}) = { :media => :all }.merge path = self.class.use_bundled_assets ? generate_versioned_name(path) : path stylesheet = asset_path(path, :type => :stylesheet) %{<link href="%s" rel="stylesheet" type="text/css" media="%s"></link>} % [ stylesheet, [:media].to_s ] end |