From 04d0555c1109390ab5b2e949d3b971b627ff880a Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 31 May 2015 05:38:53 +0900 Subject: [PATCH] Render begin, rescue and ensure in silent script --- lib/hamlit/parsers/script.rb | 2 +- spec/hamlit/engine/silent_script_spec.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/hamlit/parsers/script.rb b/lib/hamlit/parsers/script.rb index 4d33406e..47046ff3 100644 --- a/lib/hamlit/parsers/script.rb +++ b/lib/hamlit/parsers/script.rb @@ -10,7 +10,7 @@ module Hamlit include Concerns::Error include Concerns::Indentable - INTERNAL_STATEMENTS = %w[else elsif when].freeze + INTERNAL_STATEMENTS = %w[else elsif rescue ensure when].freeze DEFAULT_SCRIPT_OPTIONS = { force_escape: false, disable_escape: false }.freeze included do diff --git a/spec/hamlit/engine/silent_script_spec.rb b/spec/hamlit/engine/silent_script_spec.rb index efc5d21f..c73b4122 100644 --- a/spec/hamlit/engine/silent_script_spec.rb +++ b/spec/hamlit/engine/silent_script_spec.rb @@ -152,6 +152,20 @@ describe Hamlit::Engine do HTML end + it 'renders begin-rescue' do + assert_render(<<-'HAML', <<-HTML) + - begin + - raise 'error' + - rescue + hello + - ensure + world + HAML + hello + world + HTML + end + it 'joins a next line if a current line ends with ","' do assert_render("- foo = [', \n ']\n= foo", <<-HTML) [", "]