#
# Usage:
#
#
# ...
#
# ...
#
$wgExtensionFunctions[] = "wcRecipeBook";
function wcRecipeBook() {
global $wgParser;
$wgParser->setHook( "recipe", "Recipe" );
$wgParser->setHook( "ingredients", "ingredientList" );
}
# The outside recipe tag. Takes two options: "serves" and "from"
function Recipe($input, $argv){
global $wgOut;
$serves = $argv["serves"];
$from = $argv["from"];
$output .= "
";
$output .= "Serves: $serves";
$output .= "$from";
$output .= "
";
# We need to parse our input to find the 'ingredients' tag
# I don't know if this is the proper way to do this, but it works
$output .= $wgOut->parse($input);
$output .= "
";
return $output;
}
# Creates a nice two-column ingredient list
function ingredientList( $input, $argv ) {
$inglist = explode("\n", $input);
if($inglist[0] == ""){
array_shift($inglist);
}
if($inglist[count($inglist)-1] == ""){
array_pop($inglist);
}
$output = "