Sha256: 15d9e64ec6fc831003c890afe46b8ee20d98cae5683476b7f2fc0ef80f43af37

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module BiolaFrontend
  module Rails
    module FrontendToolkitHelper

      def show_environment
        unless ::Rails.env.match(/prod/i)
          content_tag :span, ::Rails.env, class: 'label label-danger'
        end
      end

      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

      def app_dropdown_link(dropdown, &block)
        link_options = {'class'=>'dropdown-toggle'}
        link_options = {'class'=>'dropdown-toggle', 'area-hidden'=>'true', 'data-toggle'=>'dropdown'} if dropdown
        link_to (dropdown ? '#' : BiolaFrontendToolkit.config.relative_root), link_options do
          yield if block_given?
        end
      end

      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

      # Replaces http:// and https:// with just //
      def strip_scheme(url)
        url.to_s.gsub(/\Ahttps?:/, '')
      end

      def schemeless_image_tag(url)
        image_tag strip_scheme(url)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
biola_frontend_toolkit-0.5.0 app/helpers/biola_frontend/rails/frontend_toolkit_helper.rb