[pmwiki-users] cookbook-recipeinfo was: Summary line in PITS and Cookbook

Patrick R. Michaud pmichaud at pobox.com
Sun Aug 20 23:03:07 CDT 2006


On Sun, Aug 20, 2006 at 10:41:05PM -0400, Crisses wrote:
>    Hi,
>    I am very interested in figuring out exactly what "recipeinfo" is doing in
>    the Cookbook.

Actually, "recipeinfo" itself doesn't do anything -- it's just
a normal div that puts a gray box around its contents.  :-)

Yes, I'm serious.

The code that does the "magic" in the cookbook is a special markup
rule that records "properties", and a way of saving those properties
as page attributes and reading them as page variables.  The markup is:

    Markup('^Property:', 'directives',
      '/^([A-Z][-\\w]+):(\\s.*)?$/e',
      "'<:block,0><div class=\'property-$1\'>'.PSS('$0').'</div>' .
       PZZ(SetProperty(\$pagename, 'recipe$1', PSS(trim('$2'))))");

This says that every markup line beginning with a capitalized
word and a colon is saved as a "recipe" property in the page.  
Thus a markup like

    Summary: This is a summary

stores the value "This is a summary" as a "recipeSummary" property.

The rest of the code handles saving selected properties as
attributes, and making them available as page variables:

    foreach(array('Summary', 'Version', 'Votes') as $p) {
       $SaveProperties[] = "recipe$p";
       $FmtPV["\$Recipe$p"] = "@\$page['recipe$p']";
    }

Thus, lines in a cookbook page beginning with "Summary:", "Version:",
or "Votes:" are automatically saved to page files, and they can be
accessed via the {$RecipeSummary}, {$RecipeVersion}, and
{$RecipeVotes} page variables.

This approach is still somewhat in its formative stages -- I'm
wanting to make a bit of a cleaner interface for dealing with
page properties and attributes in general.  But the approach
should also be relatively safe with respect to future versions
of PmWiki.

Pm





More information about the pmwiki-users mailing list