[Petal] Multiple conditions?

jhiver at mkdoc.com jhiver at mkdoc.com
Sun Mar 9 23:01:11 GMT 2003


Hi Ronald,

> I'd be happy to provide some examples.  I should get code-reviewed on
> them, though, since I'm still a newbie.

Sure :-)

> using the $.  So I started putting it in for consistency -- and because
> once I'm done with the first pass, it will be non-programmers
> maintaining this, and it's not going to be fair to make them try and
> remember "For the same word, you put $ here but not over here..."

True, true. Basically the rule is you need the dollar sign with inline
syntax
or a within a string: modifier. Personally I try to avoid them as much as
possible because I find them ugly.

I've been thinking of removing the inline syntax in the past but your case
clearly shows that TIMTOWTDI is a good thing... I'm not a dictator, so
whichever way you can find Petal useful makes me happy :-)


> The final results are along these lines (consider it my first example!):
>
> <page petal:set="chapters $book/chaptersContainingNamedDescendants
> 'Figure' 'CodeListing' 'Table'"

Personally I'd remove the $ and use double dashes, but that's a matter
of taste and after all you might want to stick with the conventions you've
already set.

> <chapter_title internal-destination="$chapter/page_ref"
> petal:content="structure $chapter/name"></chapter_title >

The strength of Petal is that you can use dummy values everywhere...
if your designers use WYSIWYG tools, the following will probably
work better:

<chapter_title
    internal-destination="dummy_internal_destination"
    petal:attributes="internal-destination chapter/page_ref"
    petal:content="structure chapter/name">Dummy Chapter</chapter>

One of the advantages of using petal:attributes is that if the expression
evaluates to undef or empty string, the attribute is removed, which is
almost always what you want.


>              <chapter_page ref-id="$chapter/page_ref" />

Again,

<chapter_page
    ref-id="dumb-id"
    petal:attributes="ref-id chapter/page_ref" />


Cheers,
Jean-Michel.




More information about the Petal mailing list