harrydeluxe / php-liquid

A PHP port of Ruby's Liquid Templates
http://www.delacap.com/artikel/Liquid-Templates/
MIT License
239 stars 119 forks source link

toLiquid doesn't get called for objects inside objects #40

Closed sanmai closed 7 years ago

sanmai commented 7 years ago

Let's say we have an object which have another object bound to one of the properties.

class NestedObject
{
    public $property;
    public $value = -1;

    public function toLiquid() {
        return array(
            'property' => $this->property,
            'value' => 42,
        );
    }
}

For the sake of example let's use the same object type.

$object = new NestedObject();
$object->property = new NestedObject();

Now, if we would try accessing embedded object's property...

{{ object.property.value }}

We'll get not 42 as we may expect from having it set in toLiquid but -1.