From 51ebc56f89f08054c0b7bb46f1597273aefc1b18 Mon Sep 17 00:00:00 2001 From: Simon Cossar Date: Tue, 14 Apr 2015 19:50:55 -0700 Subject: [PATCH] Move 'if defined?' conditional to before 'require' statement for r2 gem --- lib/sass/discourse_sass_compiler.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/sass/discourse_sass_compiler.rb b/lib/sass/discourse_sass_compiler.rb index bde2f84db00..bccb3c239dc 100644 --- a/lib/sass/discourse_sass_compiler.rb +++ b/lib/sass/discourse_sass_compiler.rb @@ -66,11 +66,13 @@ class DiscourseSassCompiler # Check if CSS needs to be RTLed after compilation # and run R2 gem on compiled CSS if true and R2 gem is available css_output = css - if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) - begin - require 'r2' - css_output = R2.r2(css) if defined?(R2) - rescue; end + if defined?(R2) + if !SiteSetting.allow_user_locale && SiteSetting.default_locale.in?(%w(he ar fa_IR)) + begin + require 'r2' + css_output = R2.r2(css) + rescue; end + end end css_output end