Sha256: 0517179135c0d3595ee1514b3edfc45f543c96c1106a8f5def6ed1b68e91310d

Contents?: true

Size: 957 Bytes

Versions: 6

Compression:

Stored size: 957 Bytes

Contents

module I18nline
  module ActionViewExtension
    extend ActiveSupport::Concern

    included do
      def current_user_can_translate?
        I18nline.current_user ||= send I18nline.current_user_method
        if I18nline.current_user
          if I18nline.current_user.try I18nline.can_translate_method
            return true
          end
        end
        false
      end
    end

    def i18nline_assets_inclusion_tag
      if current_user_can_translate?
        assets = ""
        assets << i18nline_host_styles << "\n"
        assets << i18nline_host_javascripts << "\n"
        assets.html_safe
      end
    end

    private

      # Javascripts that will be loaded on host application:
      def i18nline_host_javascripts
        javascript_include_tag("i18nline_to_host.js")
      end

      # Css that will be loaded on host application:
      def i18nline_host_styles
        stylesheet_link_tag("i18nline_to_host.css")
      end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
i18nline-0.0.15.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.14.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.12.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.11.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.10.alpha lib/i18nline/action_view_extension.rb
i18nline-0.0.8.alpha lib/i18nline/action_view_extension.rb