Hi, I've seen recently a lot of code like this:

$html = Html::openElement( 'div', array( 'class' => 'foo' )
    . Html::rawElement( 'p', array(),
        Html::element( 'span', array( 'id' => $somePotentiallyUnsafeId ),
            $somePotentiallyUnsafeText
        )
    )
    . Html::closeElement( 'div' );

IMO, cruft like this makes things harder to read and adds additional
performance overhead. It can be simplified to

$html = '<div class="foo'><p>'
    . Html::rawElement( 'p', array(),
        Html::element( 'span', array( 'id' => $somePotentiallyUnsafeId ),
            $somePotentiallyUnsafeText
        )
    )
    . '</p></div>';

What's your opinion, guys and gals?

-- 
Best regards,
  Max Semenik ([[User:MaxSem]])


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

Reply via email to