Template Macros
Showcasing how to define and invoke macros for generating dynamic content like links, Wikipedia references, video embeds with subtitles, and code blocks with parameterized substitutions
September 22, 2025
Samantha Monty
Chair for Human-Computer Interaction, University of Würzburg

Introduction to Template Macros

Template macros allow dynamic content generation in presentations by defining reusable templates for links, media, and code blocks. This deck demonstrates their definition and invocation.

Basic Macro: Definition

Template: test

templates:
  test: :(1) :(2) :(3) [:(title)](:(url))

This macro combines three arguments with a titled link.

Basic Macro: Invocation

Using the test Macro

[@test arg1 arg2 arg3](the%20url "Title")

Invokes the test macro with three arguments, a URL, and a title.

Basic Macro: Result

Output of test and test2

Shows the rendered result of the test and test2 macros.

Video Macro: Definition

Template: video

templates:
  video: |
    ```{=html}
    <video controls style="width: var(--slide-width); height: var(--slide-height);">
    <source src=":(url)" type="video/mp4" />
    <track kind="subtitles" label="Deutsch" srclang="de" src=":(title)" default />
    </video>
    ```

Defines a macro for embedding videos with subtitles.

Video Macro: Invocation

Using the video Macro

[@video](/videos/myvideo.mp4 "/videos/mycaptions.vtt")

Invokes the video macro with a video URL and subtitle file.

Video Macro: Result

Output HTML

<video controls style="width: var(--slide-width); height: var(--slide-height);">
<source src="/videos/myvideo.mp4" type="video/mp4" />
<track kind="subtitles" label="Deutsch" srclang="de" src="/videos/mycaptions.vtt" default />
</video>

Shows the generated HTML for the video embed.

Code Block Macro: Example

Using the block-test Macro

:(1) :(2) :(3) p1 p2 The Block Test Code

Demonstrates a code block macro with parameterized substitutions.

Source code

# Code Block Macro: Example

## Using the `block-test` Macro

``` {.arg1 .arg2 .arg3 macro="block-test" 
param1="p1" param2="p2"}
The Block Test Code
```
Demonstrates a code block macro with parameterized substitutions.