Skip to content

Access array elements in shortcodes like {{< meta >}} #6769

@cderv

Description

@cderv

Discussed in #6764

Originally posted by multimeric September 8, 2023

Description

The quarto documentation explains how to use metadata within the document, and also how to access nested values using the dot notation: https://quarto.org/docs/authoring/variables.html. However, it doesn't explain how to access array/list elements, and indeed I can't find a syntax that supports this.

In the following document I show my attempts to do this:

---
top: "Top Lvel"
nested:
    str: "Nested String"
    array:
        - foo
        - bar
---

{{< meta top >}}
{{< meta nested.str >}}
{{< meta nested.array[0] >}}
{{< meta nested.array[1] >}}
{{< meta nested.array.0 >}}
{{< meta nested.array.1 >}}

This renders to PDF like this, showing that none of my attempted array accesses worked:

Screen Shot 2023-09-08 at 11 57 41 am

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions