I have a loader that loads objects. If the object implements a Project_ResourceInterface, that provides a method getSource(), then the loader can handle this object and return the source.
It works very, very well. I can have the following sintax in my templates:
{{ include page.part.body }} -- or something similar
The only problem is this line at Twig_Environment class:
return $this->loadedTemplates[$name] = new $cls($this);
If $name is a object, I get a PHP Illegal offset type error. I've changed that to:
return $this->loadedTemplates[(string) $name] = new $cls($this);
and each of my resources have a __toString method that returns a unique identifier.
I think you could make that a bit more flexibe if those loadedTemplates was generated in a more flexibe way, maybe calling a method from the loader.
I have a loader that loads objects. If the object implements a Project_ResourceInterface, that provides a method getSource(), then the loader can handle this object and return the source.
It works very, very well. I can have the following sintax in my templates:
{{ include page.part.body }} -- or something similar
The only problem is this line at Twig_Environment class:
If $name is a object, I get a PHP Illegal offset type error. I've changed that to:
and each of my resources have a __toString method that returns a unique identifier.
I think you could make that a bit more flexibe if those loadedTemplates was generated in a more flexibe way, maybe calling a method from the loader.