Sha256: 5e71f3d3f93b6b7feeaf9856af384ba5d2a36d9972ae21c85b3130efef422e18

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

require 'uglifier'

module Middleman
  module GoogleAnalytics
    module Helpers

      def google_analytics_tag
        render_script('ga.js.erb')
      end

      def google_analytics_universal_tag
        render_script('analytics.js.erb')
      end

      private

      def render_script(template)
        return nil if development? && !google_analytics_settings.development

        @options = google_analytics_settings
        file = File.join(File.dirname(__FILE__), template)
        content = ERB.new(File.read(file)).result(binding)
        content = Uglifier.compile(content) if google_analytics_settings.minify
        content_tag(:script, content, type: 'text/javascript')
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-google-analytics-1.1.0 lib/middleman-google-analytics/helpers.rb