diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8f833159..321bc42f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -295,7 +295,7 @@ module ApplicationHelper projects.each do |project| s << "\n" end - s + s end # Truncates and returns the string as a single line @@ -487,14 +487,17 @@ module ApplicationHelper Rails.logger.debug msg end rescue Liquid::SyntaxError => exception + msg = "[Liquid Syntax Error] #{exception.message}" if Rails.logger && Rails.logger.debug? - msg = "[Liquid Syntax Error] #{exception.message}\n:\n#{exception.backtrace.join("\n")}" - msg << "\n\n" - Rails.logger.debug msg + log_msg = "#{msg}\n" + log_msg << exception.backtrace.collect{ |str| " #{str}" }.join("\n") + log_msg << "\n\n" + Rails.logger.debug log_msg end # Skip Liquid if there is a syntax error - text = h(input_text) + text = content_tag(:div, msg, :class => "flash error") + text << h(input_text) end @parsed_headings = [] diff --git a/test/unit/lib/chili_project/liquid_test.rb b/test/unit/lib/chili_project/liquid_test.rb index 3425e313..272dfce9 100644 --- a/test/unit/lib/chili_project/liquid_test.rb +++ b/test/unit/lib/chili_project/liquid_test.rb @@ -229,5 +229,13 @@ class ChiliProject::LiquidTest < ActionView::TestCase formatted = textilizable(text) assert_match '<script>alert("Hello")</script>', formatted end + + should "have an error flash" do + text = "{% --- something invalid %}\n" + formatted = textilizable(text) + + assert_match /flash error/, formatted + assert_match '[Liquid Syntax Error]', formatted + end end end