In earlier versions of Plates all template data was made available to all templates. Meaning this main template being rendered, as well as any layouts and nested templates. However, we received complaints with that approach. Each template was not isolated, and unexpected variable overwriting could occur. So in Plates 3.x each template became its own instance of Template, isolating it from the other templates.
I actually liked this change. It meant you had to explicitly set the data passed to each template. Both layouts and nested templates got the option to pass down an array of template data. We also added the ability to set "global" data using the addData() method, helpful for things like layout template data.
That all said, it does seem more common for template engines (Twig/Blade) to make data accessible to all templates. We're also getting requests for this old behaviour. (#77, #83). I've opened this issue to simply revisit this for the 4.x release. This can be a place for discussion on whether the current implementation is good, or if we should change this back again.
well, I think with something like #77, nothing would get overridden because anything you define to be passed in would be overridden.
Another option would be to add a helper method in the template that will allow users to override the current data in the current template.
<?php $this->insert('tpl', $this->override([
'name' => 'John',
So, this would just simply be an alias of array_merge($this->data, ['name' => 'John'])
array_merge($this->data, ['name' => 'John'])