From 5d7bc6ec3d0936b9f658731b4dd28c4853b147d8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 6 Jul 2026 14:50:01 +0300 Subject: [PATCH] docs... Signed-off-by: Alex A. Naanou --- v3/bootstrap/Doc/Macros.md | 88 ++++++++++++++++++++------------------ v3/pwiki/parser.js | 11 ++--- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/v3/bootstrap/Doc/Macros.md b/v3/bootstrap/Doc/Macros.md index 2b10594..11d3a41 100755 --- a/v3/bootstrap/Doc/Macros.md +++ b/v3/bootstrap/Doc/Macros.md @@ -137,6 +137,8 @@ bot from within pWiki as well as outside. ### now () +XXX + ``` \@now() ``` @@ -295,8 +297,6 @@ Will render to: `original [ ]` > ... - - ... ``` @@ -331,6 +331,51 @@ Arguments: ]]--> +### macro (_name_ _src_ _join_ _else_) / else + +Define and/or apply a macro. + +``` + + ... + + ... + + +``` + + +If `name` is given a _named macro_ is defined. This macro can be later +referenced (used) by name. A named macro can be redefined/overridden. + +If `src` is given then expand the macro in applied to (i.e. expanded +in the context of) a page or range of pages and the result is included +in the current page. + +This differs frome `@include(..)` in that it does not load the rource +page, it only executes macros in it's context. + +Both `name` and `src` are optional. + +For a macro to be useful it must have a body (or a `text`/`body` attribute), +either defined as a named macro or in the current macro. + +The `` macro (or `else` attribute) is used if the `src` does not match +any pages. + +**Example:** + + +- [bootstrap pages](/bootstrap/Templates/pages.html) + + + + --- @@ -363,45 +408,6 @@ macro at the end of the page._ -### macro (name src sort) / else () - -Apply macro to source page and include the result. - -This is similar to include but does not require a separate page. - -Both `name` and `src` are optional. - -If `name` is given a _named macro_ is defined. This macro can be later -referenced (used) by name. A named macro can be redefined/overridden. - -If `src` is given a macro is applied to a specific page or range of pages -(see: WikiPath). - -For a macro to be useful it must have a body (`text`), either defined as -a named macro or in the current macro. - -Arguments: -- `name` -- macro name (optional). -- `src` -- path to source page (optional). -- `sort` -- space separated list of methods to use for item sorting - - -`else` macro is applicable inside `macro`. it is used when the `src` path -of `macro` matches no pages. - -**Example:** - - -- [bootstrap pages](/bootstrap/Templates/pages.html) - - - - diff --git a/v3/pwiki/parser.js b/v3/pwiki/parser.js index e5642b4..07c5692 100644 --- a/v3/pwiki/parser.js +++ b/v3/pwiki/parser.js @@ -1548,16 +1548,13 @@ module.parser = { // that .match(..) can not know about... // XXX should we do the same for offset??? // - // XXX BUG: strict does not seem to work: - // @macro(src="./resolved-page" else="no" text="yes" strict) - // -> yes - // should be "no" - // ...this seems to effect non-pattern pages... + // XXX macro variables... // XXX should macro:index be 0 or 1 (current) based??? - // XXX SORT sorting not implemented yet... + // XXX sorting... // XXX check macro recursion... macro: Macro( - ['name', 'src', 'sort', 'text', 'join', 'else', + //['name', 'src', 'sort', 'text', 'join', 'else', + ['name', 'src', 'join', 'else', ['strict', 'isolated', 'inheritmacros', 'inheritvars']], lazy( function(page, args, body, state){