Module: Middleman::GoogleAnalytics::Helpers
- Defined in:
- lib/middleman-google-analytics/helpers.rb
Instance Method Summary collapse
- #google_analytics_tag ⇒ Object
-
#indent(content) ⇒ Object
Ugly but true.
Instance Method Details
#google_analytics_tag ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/middleman-google-analytics/helpers.rb', line 9 def google_analytics_tag = extensions[:google_analytics]. return nil if .disable file = File.join(File.dirname(__FILE__), 'analytics.js.erb') context = { options: } content = Erubis::FastEruby.new(File.read(file)).evaluate(context) content = Uglifier.compile(content) if .minify if .output.to_sym == :html content = indent(content) unless .minify content_tag(:script, content, type: 'text/javascript') else content end end |
#indent(content) ⇒ Object
Ugly but true
28 29 30 31 32 |
# File 'lib/middleman-google-analytics/helpers.rb', line 28 def indent(content) str = "\n" content.each_line { |line| str << line.indent(2) } str end |