From c95629a781667f5af1a3cd489522ee9fae1ee7df Mon Sep 17 00:00:00 2001 From: xdite Date: Mon, 11 Feb 2013 19:34:14 +0800 Subject: [PATCH] move google analytics to partial --- app/helpers/common_helper.rb | 7 +++++++ app/views/common/_google_analytics.html.erb | 14 ++++++++++++++ app/views/layouts/application.html.erb | 17 +---------------- 3 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 app/helpers/common_helper.rb create mode 100644 app/views/common/_google_analytics.html.erb diff --git a/app/helpers/common_helper.rb b/app/helpers/common_helper.rb new file mode 100644 index 00000000000..83ee98efa5b --- /dev/null +++ b/app/helpers/common_helper.rb @@ -0,0 +1,7 @@ +module CommonHelper + def render_google_analytics_code + if Rails.env == "production" && SiteSetting.ga_tracking_code.present? + render :partial => "common/google_analytics" + end + end +end \ No newline at end of file diff --git a/app/views/common/_google_analytics.html.erb b/app/views/common/_google_analytics.html.erb new file mode 100644 index 00000000000..79f2414e848 --- /dev/null +++ b/app/views/common/_google_analytics.html.erb @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 106abd5f98d..68e1351080c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -124,22 +124,7 @@ Discourse.initialize() - <%- if Rails.env == "production" and SiteSetting.ga_tracking_code.present? %> - - <%-end%> + <%= render_google_analytics_code %>