From b470d3d2573c482ff41afaee9c34df9294135819 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 12 Jan 2016 22:43:27 +0900 Subject: [PATCH] Refactor using :block --- lib/hamlit/compiler/script_compiler.rb | 7 +++---- lib/hamlit/compiler/silent_script_compiler.rb | 11 +++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/hamlit/compiler/script_compiler.rb b/lib/hamlit/compiler/script_compiler.rb index c23571e2..40d37f8a 100644 --- a/lib/hamlit/compiler/script_compiler.rb +++ b/lib/hamlit/compiler/script_compiler.rb @@ -73,10 +73,9 @@ module Hamlit ] else [:multi, - [:code, "#{var} = #{node.value[:text]}"], - [:newline], - yield(node), - [:code, 'end'.freeze], + [:block, "#{var} = #{node.value[:text]}", + [:multi, [:newline], yield(node)], + ], ] end end diff --git a/lib/hamlit/compiler/silent_script_compiler.rb b/lib/hamlit/compiler/silent_script_compiler.rb index 2c99654c..b5450bbe 100644 --- a/lib/hamlit/compiler/silent_script_compiler.rb +++ b/lib/hamlit/compiler/silent_script_compiler.rb @@ -12,12 +12,11 @@ module Hamlit private def compile_with_children(node, &block) - temple = [:multi] - temple << [:code, node.value[:text]] - temple << [:newline] - temple << yield(node) - temple << [:code, 'end'] - temple + [:multi, + [:block, node.value[:text], + [:multi, [:newline], yield(node)], + ], + ] end end end