SimpleRecipeTemplate

Summary: A Simple Recipe Template to provide a framework for PmWiki recipes
Version: 2022-06-11
Prerequisites: PmWiki 2.3.2; PHP 7.4
Status: Always beta
Maintainer: simon
Licence: GPL3#
Users: (view? / edit)

Questions answered by this recipe

How do I write a PmWiki recipe? Is there a blueprint I can use? Are there any recipe examples?

Description

This recipe provides a simple recipe template that illustrates and implements some PmWiki recipe concepts.

The recipe provides a multiline directive with parameters that implements a printable and hexadecimal character display of all text within the directive. The form of such a directive is

(:directivename optional parameters:) optional lines of text (:directivenameend:).

It also provides a singleline directive that implements a display of some internal PmWiki variables. The form of such a directive is

(:directivename optional parameters:).

PmWiki Developers

 This recipe illustrates some simple features of PmWiki recipes.
  • \Markup (): markup, illustrating (:directive parm=value:) text (:directiveend:)
  • \ParseArgs (): PmWiki function to create key value array from directive parameters
  • \Keep (): PmWiki function to return HTML rather than wiki markup for page
  • \SDV (): override default values from a configuration file
  • $MessageFmt: log messages to the default PmWiki logging mechanism and displayed by the (:messages:) directive
  • $HTMLStylesFmt: insert CSS for the recipe into the page
  • $HTMLHeaderFmt: insert into HTML metadata element
  • dmsg: local function providing a way to debug a recipe
  • $RecipeInfo: publish recipe version for PmWiki Site Analyzer and Recipe Check
  • $FmtPV: create a page text variable enabling version display on a page

The recipe uses the following PHP features:

  • Type hints
  • Strict typing mode for argument and return values This assists with determining that the code behaves as expected
  • Namespaces This assists with avoiding name collisions

Installation

Usage

Place the directive, as described below, in your PmWiki page.

The recipe provides a page variable {$SimpleRecipeVersion} which contains the current version, and page variable {$SimpleRecipe} for a (:if enabled SimpleRecipe:) recipe installation check.


SimpleRecipe output

Configuration

(:simplerecipe len=# :) arbitrary text (:simplerecipeend:)

  • len= -- number of characters to display per line, defaults to 16

Parameters are case-insensitive.


VerySimpleRecipe output (truncated)

A second example is (:verysimplerecipe:) If no parameters are supplied this directive will display the directives it accepts. You can use this recipe to display some internal PmWiki arrays. These include:

config.php settings

You can change the following in config.php. For example

$SimpleRecipeDebug = true; # results may vary

Change log / Release notes

2022-06-11 Addmore outputs, use PHSC 2022-04-24 Add some parameters to verysimplerecipe 2022-01-22 Initial version

See also

On PmWiki

From the PmWiki developer category:

Contributors

Special thanks to Petko and the PmWiki documenters.

Comments

See discussion at SimpleRecipeTemplate-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.