[TYPO3-50-general] Beer3, really a good solution?

Bastian Waidelich bastian at typo3.org
Mon Oct 27 11:19:17 CET 2008


Georg Ringer wrote:

Hi Georg,

In case, you're still not convinced, I'd like to add my 5 cents (:
I (have to) work with PHP based templates too in my daily work and I 
think it's a big advancement compared to the old marker-based way where 
you'd have to deal with presentation all over the place (by filling the 
markers with (HTML)-content).

But using PHP in your template _might_ lead to a few issues:

1. Reusability
If you create a "select field with dates from 1900 to 2000", you'll have 
to copy/paste it in order to use it somewhere else. And copy/paste is 
*evil* ;)

2. Bulky views
It's not good to have too much logic in your view, because that makes it 
really difficult to track down errors in your (complex) application. If 
you _separate the concerns_, it's much easier to know where to fix an 
error when it occurs - and it _will_ occur eventually. *g

3. Testability
My favorite: Templates are not testable.¹
While you can easily unit-test model and controller, this is hardly 
possible with your view. That's another reason why you want to keep the 
view as dump as possible.


Regarding a counter (e.g. to create alternating table columns), we were 
thinking about an optional "counter"-parameter in the for view helper. 
What do you all think about this:

<f3:for each="{posts}" as="post" counter="i">
	<tr {f3:if(condition="{i} % 2 != 0", 'class="odd"')}>
	...
</f3:for>


Bastian

--
¹ I know, there are ways to test the output (selenium...), but that 
should be done _additionally_ to unit tests IMO.


More information about the TYPO3-project-5_0-general mailing list