Skip to content

Commit dbadbce

Browse files
committed
contextualize value before invoking to_liquid
1 parent 28f31d0 commit dbadbce

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/liquid_c/context.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ inline static VALUE value_to_liquid_and_set_context(VALUE value, VALUE context_t
4444
if (klass == rb_cString || klass == rb_cArray || klass == rb_cHash)
4545
return value;
4646

47-
value = rb_funcall(value, id_to_liquid, 0);
48-
4947
if (rb_respond_to(value, id_set_context))
5048
rb_funcall(value, id_set_context, 1, context_to_set);
5149

52-
return value;
50+
VALUE liquid_value = rb_funcall(value, id_to_liquid, 0);
51+
52+
if (value != liquid_value && rb_respond_to(liquid_value, id_set_context))
53+
rb_funcall(liquid_value, id_set_context, 1, context_to_set);
54+
55+
return liquid_value;
5356
}
5457

5558

0 commit comments

Comments
 (0)