diff --git a/lib/liquid/tags/include.rb b/lib/liquid/tags/include.rb index 3fdc8429..0664f5c3 100644 --- a/lib/liquid/tags/include.rb +++ b/lib/liquid/tags/include.rb @@ -52,7 +52,7 @@ module Liquid def render_to_output_buffer(context, output) template_name = context.evaluate(@template_name_expr) - raise ArgumentError, options[:locale].t("errors.argument.include") unless template_name + raise ArgumentError, options[:locale].t("errors.argument.include") unless template_name.is_a?(String) partial = PartialCache.load( template_name, diff --git a/test/integration/tags/include_tag_test.rb b/test/integration/tags/include_tag_test.rb index 10385157..91f1aeab 100644 --- a/test/integration/tags/include_tag_test.rb +++ b/test/integration/tags/include_tag_test.rb @@ -249,6 +249,11 @@ class IncludeTagTest < Minitest::Test "{% include nil %}", render_errors: true) end + def test_render_raise_argument_error_when_template_is_not_a_string + assert_template_result("Liquid error (line 1): Argument error in tag 'include' - Illegal template name", + "{% include 123 %}", render_errors: true) + end + def test_including_via_variable_value assert_template_result("from TestFileSystem", "{% assign page = 'pick_a_source' %}{% include page %}", partials: { "pick_a_source" => "from TestFileSystem" })