rainphp/raintpl3 — Issue #8: Feature Request: Fluent Interface and Factory
Author: solidsnake
Created: 2012-01-12 07:51:27+00:00
State: open

Hi, I've found rainTPL a few days ago and have to say: I like what it's all about!
But I have one small feature request: Could you build in the fluent-interface and a factory method?

All you have to do is to return $this at the end of each setter (like "assign()", "configure()", "clean()", "register_tag()", ...). Then it's possible to build code that looks like this:

~~~
raintpl::factory('template', 86400) // template name and expire-time (both optional).
->assign("name", $name)
->assign("name2", $name2)
->draw("my_template");
~~~

The factory method is just an static method, which looks something like this:

~~~
public static factory($name='', $expire=null) {
$instance = new raintpl;
$instance
->set_template($name) // Method to set the template name.
->set_expiration($expire); // Method to set the expiration-time.
return $instance;
}
~~~

I hope you like the idea, if you like I can send you a pull request the next days!

P.S.: Sorry for the "issue"