thephpleague / plates

Native PHP template system
https://platesphp.com
MIT License
1.47k stars 180 forks source link

Proposal: new batch magic function #42

Closed lalop closed 10 years ago

lalop commented 10 years ago

I just come to see the issue about batch and escape. I imagined an solution using magic function, for exemple instead of :

$this->escape($foo, 'uppercase');

We can write :

$this->escapeAndUppercase($foo);

or

$this->escape_uppercase($foo);

And batch as many function we want.

reinink commented 10 years ago

Nifty idea, but I see a few issues.

First, for legibility I've avoided using camelCase for any Plates template functions. In fact, I've kept all functions to just one word (no underscores).

Simply using underscores would be unreliable since many PHP functions use underscores. Consider:

// Is this (escape & strip_tags) or (escape, strip & tags)?
$this->escape_strip_tags($foo);

Using an "and" separator would fix this, but it does make things a little longer:

$this->escape_and_strip_tags($foo);

I don't know, I like the idea, but I'm not big on the implementation.