* Ilmari Karonen <[email protected]> [Tue, 25 Aug 2009 16:54:42 +0300]:
> Nikola Smolenski wrote:
> > Ilmari Karonen wrote:
> >> Tim Starling wrote:
> >>> Html::img( array( 'src' => $src, 'alt' => $alt ) );
> >>
> >> ...although at that point you might almost as well just go the 
extra
> >> step and make it:
> >>
> >> Html::element( 'img', array( 'src' => $src, 'alt' => $alt ) );
> >
> > Why not go full way:
> >
> > Html::doStuff( array( 'what' => 'element', 'element' => 'img', 'src'
> =>
> > $src, 'alt' => $alt ) );
>
> Well, my point was really that the process of constructing a 
well-formed
> HTML (or XML) element is pretty much independent of what the element's
> name is, so any convenience functions like the putative Html::img() 
just
> end up being thin wrappers around a generic element-building function
> anyway.  If the wrappers end up *so* thin that they all just look like
> this:
>
> public static function img( $attribs = array() ) {
>      return self::element( 'img', $attribs );
> }
>
> then they don't really add much convenience anymore and might as well 
be
> dispensed with.
>
>
> > Seriously, I see a logical distinction between obligatory (every 
image
> > must have a src) and non-obligatory parameters, so perhaps this 
would
> be
> > the best:
> >
> > Html::img( $src, array( 'alt' => $alt ) );
> >
> > It should not be a problem to remember parameter order when there is
> > only one parameter.
>
> Nah, surely that would be way too sensible. :)
>
I think that much more important would be building a DOM-like tree from 
these to be able to add/remove tags and their attributes on the fly. 
Shouldn't be extremly hard for nested arrays/objects (my extension has 
it, though in the simplified way).
Dmitriy

_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to