Templates
Summary
Templates are notes whose content can be copied to other notes.
Templates can either be applied into an open note with the Apply Template, or automatically applied at note creation with Schemas, or through Create New with Template
option during lookup.
Use Cases
- daily journal templates
- meeting templates
- project templates
Features
Reusable Notes
Instead of starting from scratch, create notes that can be re-used inside of other notes
### Grocery Checklist
- [ ] buy milk
- [ ] buy flowers
- [ ] buy eggs
Variable Substitution
NOTE: Only available when using Schema Templates
Add custom variables in your Frontmatter and use them inside of your templates
---
...
name: John
---
Hello {{fm.name}},
Congratulations on the offer!
Template Variables
NOTE: Only available when using Schema Templates
Dendron comes with pre-defined template variables that are automatically included in your templates at run time.
You can see the full list here
Comments
Comment your template to remember the context.
<!-- Markdown comment, will show up when template is applied -->
{{! Handlebar comment, will be stripped out when template is applied }}
Conditionals
Use if/else clauses to conditionally apply templates
Hello
To whom it may concern,
Built-in Helpers
Built-in helper functions that can be used with handlebar templates
Example: Conditionally add a block depending on day of week
- NOTE: since we are getting the day of the week based on the file name instead of the current day, this will work even when you create the note in advance
{{#if (eq (getDayOfWeek (fnameToDate)) 0) }}
- [ ] do laundry
{{/if}}
Components
Handlebar Templates
Use handlebars, a powerful templating language which enables conditionals, for loops and custom helpers to apply to your templates without executing code.
Getting Started
A template is just a regular note. While any note can be a template, we recommend adding templates in the [[template]]
hierarchy of your vault.
-
Create a template note. Use lookup and create the note
template.pr-check-list
-
Copy and paste the following contents
## Tasks - [ ] code is tested - [ ] code has proper commit message - [ ] code does not impact performance
-
Create a new note
task.code-check-in
-
Choose
template.pr-check-list
-
Congrats, you just applied your first template!
Children
- Features
- Schema Template: Automatically apply a template when it matches a particular hierarchy pattern
- Template Variables: Pre-defined template variables that are automatically included in your templates at run time
- Template Helpers: Built-in helper functions that can be used with handlebar templates
- Components
- Handlebar Templates: Use handlebars, a powerful templating language which enables conditionals, for loops and custom helpers to apply to your templates without executing code
- Commands
- Commands: Template Specific Commands
Backlinks