[Fwd: Re: [Koha-devel] template system abuse]

Robert Flach, Poet and Critic webmaster at allauthors.com
Thu Apr 13 23:27:49 CEST 2006


>
> What's your opinion about replacing links with form buttons?
>   
In general I'm in agreement with you.  If the action has no side effects 
(this is not the same as being non-destructive; many actions may be 
non-destructive but nevertheless have important side affects [though all 
destructive actions are necessarily side affects]) it should be in an 
<a> tag.  If the action has side effects, it should be in a 'post' 
method form.  I would still object to the 'URL' variable for the 
following reasons:
1. When I am looking at the template and I see a link, I want to know 
where that link goes to.  The 'url' variable hides this important piece 
of information from the template designer.
2. As a 'general' rule (you can always find exceptions) the only things 
which should be substituted into a template are those things which are 
dynamic and may change.  The url is not, only its parameters are.  I 
would want a more important reason than the clutteredness of the 
template to override this principle (there may be one, but I haven't 
heard it).
3. If a side-affect is later added to the action, the developer doesn't 
have to be bothered with changing things up to switch the code, he can 
pawn that off on the template designer.  (Granted they may be one and 
the same, but the separation of duties is a Good Thing(tm) IMO).

> That's the goal of everybody here :-) Hope you don't think I want to
> break anything. I want to improve based on my ideas and experience. If I
> say mistakes sometimes, no problem for recognizing it!
>
>   
Oh I hope you didn't think I was digging at you.  I've been very pleased 
(not that my pleasedness or not matters) with most of your suggestions 
and improvements.  I really did intend the above as a) a compliment to 
the whole koha team and b) an encouragement to keep doing what you're 
doing (again to the whole koha team).  I certainly didn't intend to 
imply that you would try to make it less (though I was implying that 
following my suggestion was the path of more robustness in this 
particular case) :).

I'm going to go ahead and combine your emails and respond to your other 
one here as well.

>You don't know in advance the number of level. It can be 2 or 10. Is
>that feasible in a template engine? (not with simple template engine in
>my opinion). Personnaly, I resigned and coded it into PHP and gave an
>HTML string to the template. I'm not sure this case happens in Koha,
>but I think it's to easy to say "no HTML in script".
>
>Robert, you're opinion? (a solution for my problem?)

Good criticism and question.  I should have said "no HTML in script 
unless it is unfeasable (not merely difficult or cumbersome) to 
accomplish in the template".  Always there are exceptions to every rule 
of course. 

The solution to your particular problem can be achieved in any template 
system which supports recursive includes with passed variables (PHP's 
Smarty and Perl's Template Toolkit can both do so; I'm not sure about 
HTML::Template or other templating options).  I'm also not sure how that 
would play with the translation stuff going on in koha.  Your problem 
can also be solved by transforming the problem from a recursive one to 
an iterative one, but I've always had trouble with that (I can do it if 
I have to but I'd rather use recursion unless performance is a real 
problem).

Thanks for the interesting discussion.
Robert













More information about the Koha-devel mailing list