From 7aed2f122c1940a182cde710559e78fcf91b1ee0 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 6 Oct 2020 15:55:55 -0400 Subject: [PATCH] Refactor raising tag never closed to method --- lib/liquid/block.rb | 8 +++++--- lib/liquid/tags/raw.rb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/liquid/block.rb b/lib/liquid/block.rb index e6dac4d..47d5f25 100644 --- a/lib/liquid/block.rb +++ b/lib/liquid/block.rb @@ -47,6 +47,10 @@ module Liquid end end + def raise_tag_never_closed(block_name) + raise SyntaxError, parse_context.locale.t("errors.syntax.tag_never_closed", block_name: block_name) + end + def block_name @tag_name end @@ -73,9 +77,7 @@ module Liquid @blank &&= body.blank? return false if end_tag_name == block_delimiter - unless end_tag_name - raise SyntaxError, parse_context.locale.t("errors.syntax.tag_never_closed", block_name: block_name) - end + raise_tag_never_closed(block_name) unless end_tag_name # this tag is not registered with the system # pass it to the current block for special handling or error reporting diff --git a/lib/liquid/tags/raw.rb b/lib/liquid/tags/raw.rb index a374ddd..3a5b990 100644 --- a/lib/liquid/tags/raw.rb +++ b/lib/liquid/tags/raw.rb @@ -21,7 +21,7 @@ module Liquid @body << token unless token.empty? end - raise SyntaxError, parse_context.locale.t("errors.syntax.tag_never_closed", block_name: block_name) + raise_tag_never_closed(block_name) end def render_to_output_buffer(_context, output)