---
title: yaml_property
description: "Serialize a complete YAML property."
---

# yaml_property

Serialize a complete YAML property.

## Syntax

```knap
{{ value | yaml_property:"name" }}
```

## Usage

- One non-empty property name is required. Quote names that contain spaces or punctuation.
- Scalars appear beside the key. Non-empty arrays and objects use block style beneath the key with two-space indentation; empty collections stay inline as `[]` or `{}`.
- Uses the same value serialization as `yaml` and quotes keys when needed. Typed and serialized JSON collections are supported.
- Apply transformations such as `wikilink` before this filter. No separate `yaml` or `indent` filter is needed.
- Output has no trailing newline or frontmatter delimiters.

## Examples

### Scalar

```json title="Data"
{
  "year": 1999
}
```

```knap title="Template"
{{ year | yaml_property:"year" }}
```

```md title="Output"
year: 1999
```

### Wikilink list

```json title="Data"
{
  "directors": [
    "Lana Wachowski",
    "Lilly Wachowski"
  ]
}
```

```knap title="Template"
{{ directors | wikilink | yaml_property:"director" }}
```

```md title="Output"
director:
  - "[[Lana Wachowski]]"
  - "[[Lilly Wachowski]]"
```

### Nested object

```json title="Data"
{
  "details": {
    "year": 1999,
    "genre": [
      "Action",
      "Sci-fi"
    ]
  }
}
```

```knap title="Template"
{{ details | yaml_property:"movie" }}
```

```md title="Output"
movie:
  year: 1999
  genre:
    - "Action"
    - "Sci-fi"
```

### Empty list

```json title="Data"
{
  "tags": []
}
```

```knap title="Template"
{{ tags | yaml_property:"tags" }}
```

```md title="Output"
tags: []
```

## Related filters

- [yaml](/filters/yaml)
- [wikilink](/filters/wikilink)
- [indent](/filters/indent)
