-
-
Notifications
You must be signed in to change notification settings - Fork 4
Template syntax
Custom Views templates are HTML with placeholders. A placeholder reads file data, frontmatter, loop variables, Bases rows, or expressions and inserts the result into the rendered view.
<h1>{{file.basename}}</h1>
<p>{{year}}</p>
<p>{{rating}}</p>Use frontmatter properties directly by name. Use file. for built-in file data.
| Placeholder | Meaning |
|---|---|
{{file.name}} |
Filename with extension. |
{{file.basename}} |
Filename without extension. |
{{file.path}} |
Full vault path. |
{{file.folder}} |
Folder path. |
{{file.ext}} |
File extension. |
{{file.size}} |
File size. |
{{file.ctime}} |
Created time. |
{{file.mtime}} |
Modified time. |
{{file.link}} |
Internal link to the file. |
{{file.tags}} |
Tags from frontmatter and body. |
{{file.content}} |
Note body rendered as Markdown. |
{{property}} |
Any frontmatter property. |
Use bracket access for list items:
<img src="{{cover[0]}}" alt="{{file.basename}}" />
<p>{{artists[0]}}</p>Use dot access for nested objects:
<p>{{author.name}}</p>
<p>{{rating.value}}</p>If a property name contains spaces or punctuation, use bracket notation:
<p>{{file.properties["release date"]}}</p>Filters transform a placeholder value. Chain filters with pipes.
<h1>{{file.basename|title}}</h1>
<p>{{genres|join:", "}}</p>
<p>{{releaseDate|date:"YYYY"}}</p>Filters are best for formatting output. For conditions, prefer expression methods such as .length, .contains(), and comparisons. See Template logic.
String expressions support JavaScript-style regex literals:
<h1>{{file.basename.replace(/.*\s*–\s*/, "")}}</h1>For a note named Ritviz – Mimmi, this renders Mimmi.
You can also use the pipe-style replace filter:
<h1>{{file.basename|replace:"/.*\s*–\s*/":""}}</h1>Custom Views renders markdown-like placeholder values in HTML body positions. This means wikilinks from properties such as [[Artist]] become internal links.
Inside HTML attributes, values are inserted as raw strings:
<a href="{{url}}">Open</a>
<img src="{{cover[0]}}" alt="{{file.basename}}" />Use {{file.content}} when you want the note body rendered inside the view.
If a value might contain user-authored HTML and you want to display it as text, use an escaping strategy before inserting it. For expressions, escapeHTML(value) is available:
<pre>{{escapeHTML(file.content)}}</pre>| Need | Use |
|---|---|
| Insert one property | {{property}} |
| Read file metadata |
{{file.basename}}, {{file.path}}, etc. |
| Show note body | {{file.content}} |
| Format for display | Pipe filters such as date, join, title
|
| Compare values | Expression syntax in {% if %}
|
| Repeat markup | {% for item in items %} |
| Query related notes |
{% base "Name" %} blocks |