Module: BiolaFrontend::Rails::FrontendToolkitHelper
- Defined in:
- app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb
Instance Method Summary collapse
- #app_dropdown_link(dropdown, &block) ⇒ Object
- #app_link(app) ⇒ Object
- #schemeless_image_tag(url, options = {}) ⇒ Object
- #show_environment ⇒ Object
-
#strip_scheme(url) ⇒ Object
Replaces http:// and https:// with just //.
- #yield_or(name, or_content = nil, &block) ⇒ Object
Instance Method Details
#app_dropdown_link(dropdown, &block) ⇒ Object
23 24 25 26 27 28 29 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 23 def app_dropdown_link(dropdown, &block) = {'class'=>'dropdown-toggle'} = {'class'=>'dropdown-toggle', 'area-hidden'=>'true', 'data-toggle'=>'dropdown'} if dropdown link_to (dropdown ? '#' : BiolaFrontendToolkit.config.relative_root), do yield if block_given? end end |
#app_link(app) ⇒ Object
31 32 33 34 35 36 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 31 def app_link(app) icon_string = app[:icon].present? ? "#{fa_icon(app[:icon])} " : '' link_to app[:url] do (icon_string + app[:title]).html_safe end end |
#schemeless_image_tag(url, options = {}) ⇒ Object
43 44 45 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 43 def schemeless_image_tag(url, ={}) image_tag(strip_scheme(url), ) end |
#show_environment ⇒ Object
5 6 7 8 9 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 5 def show_environment unless ::Rails.env.match(/prod/i) content_tag :span, ::Rails.env, class: 'label label-danger' end end |
#strip_scheme(url) ⇒ Object
Replaces http:// and https:// with just //
39 40 41 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 39 def strip_scheme(url) url.to_s.gsub(/\Ahttps?:/, '') end |
#yield_or(name, or_content = nil, &block) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb', line 11 def yield_or(name, or_content=nil, &block) if content_for?(name) content_for(name) elsif or_content or_content elsif block_given? yield(block) else '' end end |