Recent Changes - Search:

add Cookbook page

hide

Cookbook


hide

Topics


show

Changed

Visitor's book Site map pmwiki-2.3.2

Simple Recipe Template

To do
  • change skiwi
  • remove this comment

SimpleRecipe version 2022-06-11

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: skiwi
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.

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

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

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

Parameters are case-insensitive.

VerySimpleRecipe


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

Page last modified on 2022 Jul 24 10:37

Edit - History - Recent Changes - WikiHelp - Search - email page as link -> mailto:?Subject=KiwiWiki: Simple Recipe Template&Body=From KiwiWiki: Simple Recipe Template (https://kiwiwiki [period] nz/pmwiki/pmwiki [period] php/Cookbook/SimpleRecipeTemplate) - A Simple Recipe Template to provide a framework for PmWiki recipes