Module: Proscenium::Helper
- Defined in:
- lib/proscenium/helper.rb
Instance Method Summary collapse
- #compute_asset_path(path, options = {}) ⇒ Object
-
#css_module(*names, path: nil) ⇒ String
Accepts one or more CSS class names, and transforms them into CSS module names.
- #include_assets ⇒ Object
-
#include_javascripts ⇒ String
Includes all javascripts that have been imported and side loaded.
- #include_stylesheets ⇒ Object
- #sideload_assets(value) ⇒ Object
Instance Method Details
#compute_asset_path(path, options = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/proscenium/helper.rb', line 14 def compute_asset_path(path, = {}) if %i[javascript stylesheet].include?([:type]) return Proscenium::Manifest[path] || "/#{path}" end super end |
#css_module(*names, path: nil) ⇒ String
Accepts one or more CSS class names, and transforms them into CSS module names.
28 29 30 31 |
# File 'lib/proscenium/helper.rb', line 28 def css_module(*names, path: nil) path ||= Pathname.new(@lookup_context.find(@virtual_path).identifier).sub_ext('') CssModule::Transformer.new(path).class_names(*names, require_prefix: false).join(' ') end |
#include_assets ⇒ Object
33 34 35 |
# File 'lib/proscenium/helper.rb', line 33 def include_assets include_stylesheets + include_javascripts end |
#include_javascripts ⇒ String
Includes all javascripts that have been imported and side loaded.
44 45 46 |
# File 'lib/proscenium/helper.rb', line 44 def include_javascripts SideLoad::JS_COMMENT.html_safe end |
#include_stylesheets ⇒ Object
37 38 39 |
# File 'lib/proscenium/helper.rb', line 37 def include_stylesheets SideLoad::CSS_COMMENT.html_safe end |
#sideload_assets(value) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/proscenium/helper.rb', line 5 def sideload_assets(value) if value.nil? @current_template.instance_variable_defined?(:@sideload_assets_options) && @current_template.remove_instance_variable(:@sideload_assets_options) else @current_template.instance_variable_set :@sideload_assets_options, value end end |