Skip to content

Commit

Permalink
contextualize value before invoking to_liquid
Browse files Browse the repository at this point in the history
  • Loading branch information
ggmichaelgo committed Jan 22, 2024
1 parent 28f31d0 commit dbadbce
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ext/liquid_c/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ inline static VALUE value_to_liquid_and_set_context(VALUE value, VALUE context_t
if (klass == rb_cString || klass == rb_cArray || klass == rb_cHash)
return value;

value = rb_funcall(value, id_to_liquid, 0);

if (rb_respond_to(value, id_set_context))
rb_funcall(value, id_set_context, 1, context_to_set);

return value;
VALUE liquid_value = rb_funcall(value, id_to_liquid, 0);

if (value != liquid_value && rb_respond_to(liquid_value, id_set_context))
rb_funcall(liquid_value, id_set_context, 1, context_to_set);

return liquid_value;
}


Expand Down

0 comments on commit dbadbce

Please sign in to comment.