From 704e318229ff1ee6b5b540d3f83f7a0750f2fc1e Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Tue, 30 Jul 2024 11:46:22 +0200 Subject: [PATCH] Fix object decorator docs --- website/Object Decorators.md | 9 ++++++++- website/Page Decorations.md | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/website/Object Decorators.md b/website/Object Decorators.md index 5ff2c679..57128897 100644 --- a/website/Object Decorators.md +++ b/website/Object Decorators.md @@ -15,7 +15,8 @@ objectDecorators: <>: '<>' ``` -**Note:** To make changes take effect you may have to reload your client (just refresh the page). +> **note** Note +> For changes to take effect you may have to reload your client (just refresh the page). A few things of note: @@ -26,8 +27,14 @@ A few things of note: * `pageDecoration.prefix` * `<>` like `<>` must be a YAML string-encoded expression using the [[Expression Language]], some examples together with the attribute path: * `alwaysTen: '10'` (attaches an attribute named `alwaysTen` with the numeric value `10` to all objects matching the `where` clause) + * `alwaysTrue: 'true'` (same as `alwaysTen` but with a boolean value) * `fullName: 'firstName + " " + lastName'` (attaches a `fullName` attribute that concatenates the `firstName` and `lastName` attributes with a space in between) * `nameLength: 'count(name)'` (attaches an attribute `nameLength` with the string length of `name` — not particularly useful, but to demonstrate you can call [[Functions]] here too) + +## Rules +A few rules to keep things civil: + +* Dynamic attributes _cannot override already existing attributes_. If the object already has an attribute with the same name, this value will be kept as is. * For performance reasons, all expressions (both filter and value expressions) need to be _synchronously evaluatable_. * Generally, this means they need to be “simple expressions” that require no expensive calls. * Simple expressions include simple things like literals, arithmetic, calling some of the cheap [[Functions]] such as `today()` or string manipulation functions. diff --git a/website/Page Decorations.md b/website/Page Decorations.md index 57d82c73..9db740a9 100644 --- a/website/Page Decorations.md +++ b/website/Page Decorations.md @@ -25,7 +25,7 @@ For the purposes of [[Page Decorations]], let us limit simply to some useful exa ## Example: page prefix Let’s say we want to put a 🧑 prefix on every page tagged with `#person`. We can achieve this as follows in our [[^SETTINGS]]: ```yaml -objectDecorations: +objectDecorators: - where: "tags = 'person'" pageDecoration.prefix: '"🧑 "' ``` @@ -38,7 +38,7 @@ Let’s say that adding this `pageDecoration.disableTOC` to the front matter is You can do this as follows: ```yaml -objectDecorations: +objectDecorators: - where: 'tags = "notoc"' attributes: pageDecoration.disableTOC: "true"