[pmwiki-users] Macros for PmWiki?
Petko Yotov
5ko at 5ko.fr
Sun May 3 13:59:16 PDT 2020
We have something like this, we call it include a section (template)
with variables, see
https://www.pmwiki.org/wiki/PmWiki/IncludeOtherPages#includevariable
For example, you can have a hidden section [[#macro]] in the page like
this:
(:if false:)
[[#macro]]
{$$fname}\\
(:video {$$fname}.mp4 poster={$$fname}.jpg:)
[[#macroend]]
(:ifend:)
Then to insert the macro you include it:
(:include #macro fname=MyVideo:)
(:include #macro fname=OtherVideo:)
(:include #macro fname=ThirdVideo:)
The markup in the template can be more complex, you can have more
variables.
The template can also be a separate page, especially if it is included
from more than one page.
(:include Page fname=MyVideo date="May 3, 2020" size=8mb:)
The template section may contain markup expressions, wikistyles or any
other markup (except anchors*). I'd probably try for the caption:
{(asspaced "{$$fname}")}
which would output "My Video" instead of "MyVideo"
See also $MaxIncludes in the documentation.
Petko
*) You can have anchors in the included section but then the directive
needs to specify both the first and the last anchors like (:include
page#anchor#anchorend:)
On 03/05/2020 22:31, Michael Eager wrote:
> Does PmWiki have any kind of a macro facility, where a page would
> define a macro and use it multiple times on the page?
>
> My use case would be to have a page which contains multiple links to
> videos in a table. Using the VideoAttach recipe, each link would have
> the file name of the video, the file name of the picture to display
> (replacing the video file's extension with .jpg), and the caption,
> which is again the file name of the video. That's a lot of tedious
> repetition.
More information about the pmwiki-users
mailing list