NYCPHP Meetup

NYPHP.org

[nycphp-talk] Templating engines -- chaining tangent

Cliff Hirsch cliff at pinestream.com
Thu Jan 17 22:08:28 EST 2008


On 1/17/08 5:06 PM, "John Campbell" <jcampbell1 at gmail.com> wrote:
> Class Simple_Template {
...
>    function assign($k,$v) {
>       $this->_data[$k] = $v;
>       return $this;
>    }
...
> }
...
> $tpl = new Simple_Template();
> $tpl->assign('title','My First Page')->assign('message','Hello World'); //
chainability is fun

Just a short note to highlight an important, but tangential concept here --
chaining.

$tpl->assign('title','My First Page')->assign('message','Hello World');

Very cool concept. If you haven't already done so, check out jQuery, which
makes extensive use of this concept -- a method returning the calling
object.





More information about the talk mailing list