Module: Alchemy::SiteBootstrapping::ViewHelpers
- Defined in:
- lib/alchemy/site_bootstrapping/view_helpers.rb
Instance Method Summary collapse
- #current_site_name ⇒ Object
- #favicon_path(filename) ⇒ Object
-
#javascript_for_current_site ⇒ Object
In your layout file use this view helper to render the javascript for the currently requested site Usage: ‘javascript_include_tag javascript_include_tag`.
- #site_has_javascript?(site_name) ⇒ Boolean
- #site_has_stylesheet?(site_name) ⇒ Boolean
-
#stylesheet_for_current_site ⇒ Object
In your layout file use this view helper to render the stylesheet for the currently requested site Usage: ‘stylesheet_link_tag stylesheet_for_current_site, media: ’all’‘.
Instance Method Details
#current_site_name ⇒ Object
27 28 29 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 27 def current_site_name @current_site_name ||= Alchemy::Site.current.name end |
#favicon_path(filename) ⇒ Object
31 32 33 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 31 def favicon_path(filename) asset_path "favicon/#{current_site_name.parameterize}/#{filename}" end |
#javascript_for_current_site ⇒ Object
In your layout file use this view helper to render the javascript for the currently requested site Usage: ‘javascript_include_tag javascript_include_tag`
18 19 20 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 18 def javascript_for_current_site site_has_javascript?(current_site_name) ? current_site_name.parameterize : "application" end |
#site_has_javascript?(site_name) ⇒ Boolean
22 23 24 25 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 22 def site_has_javascript?(site_name) javascripts = Rails.application.config.javascripts_for_alchemy_sites javascripts.map { |f| File.basename(f) }.include? "#{site_name.parameterize}.js" end |
#site_has_stylesheet?(site_name) ⇒ Boolean
11 12 13 14 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 11 def site_has_stylesheet?(site_name) stylesheets = Rails.application.config.stylesheets_for_alchemy_sites stylesheets.map { |f| File.basename(f) }.include? "#{site_name.parameterize}.scss" end |
#stylesheet_for_current_site ⇒ Object
In your layout file use this view helper to render the stylesheet for the currently requested site Usage: ‘stylesheet_link_tag stylesheet_for_current_site, media: ’all’‘
7 8 9 |
# File 'lib/alchemy/site_bootstrapping/view_helpers.rb', line 7 def stylesheet_for_current_site site_has_stylesheet?(current_site_name) ? current_site_name.parameterize : "application" end |