[Seaside] new header api

Philippe Marschall philippe.marschall at gmail.com
Thu Oct 26 18:45:39 UTC 2006


Hi

Now that both Seaside 2.7a1 and 2.6b1 have the "new" header API i think its time
to write something short about it so people don't have to ask.

The old header API was suffering from the same problems as the old
renderer API. Just to add an stylesheet with media and title you had
to copy and paste about 4 methods. Addional 4 for alternate
stylesheets. If you wanted a new conditional import you needed to copy
and paste a 3 LOC method.  And so on. So we followed the same path
like the Canvas API and made use of cascades.

The new API offers four base methods to create elements
- base, for base elements
- if, for conditional imports
- link, for link elements
- meta, for meta elements
- script, for script elements

Most of the time will want to use one of these two convenience methods:
- javascript, for javascripts
- stylesheet, for css stylesheets

See WABaseElement, WAConditionalComment, WALinkElement, WAMetaElement and
WAScriptElement for details

examples:

aRoot stylesheet
    url: 'styles/blue.css'

aRoot stylesheet
    document: 'a { color:red; }'

aRoot javascript
    url: 'scripts/scriptaculous.css'

aRoot if lessThan; ie7; do: [
    aRoot javascripts
        url: 'iehacks.js' ]

stuff that was just awkward to do with the old api:

aRoot link beAlternateStylesheet; beCss;
    addProjection; addPrint;
    title: 'Blue';
    url: 'styles/blue.css'

Contrary to the Canvas renderer API the new header API in the
background still used the old implementation. So you will have to
implement no methods like #rendererClass.

If you use the old API on Seaside 2.7a1 and have the development toolbar on you
will get a warning pointing to where you use the old API. These methods include
the code that you should replace yours with.

Philippe


More information about the Seaside mailing list