Obsidian Note From Template (From Template for short) is my most frequently used template plugin (I primarily use the Templater plugin for writing scripts). An updated version was finally released in the last two weeks. The new version addresses previous issues and offers more flexible dynamic features. It's highly recommended for friends to try.
1. Function Demonstration
```button
name Create New Note
type command
action From Template: from-template-Note
color purple
```
^button-newNote
```button
name Create New Book
type command
action From Template: from-template-Book2
color green
```
^button-newBook2
```button
name Open New Note Template
type link
action obsidian://advanced-uri?vault=jerry-notes&filepath=011-From-Template/From-Template-Note
color purple
```
^button-openNewNoteTemplate
```button
name Open New Book Template
type link
action obsidian://advanced-uri?vault=jerry-notes&filepath=011-From-Template/From-Template-Book2
color green
```
^button-openNewBook2Template
---
aliases:
grade: "{{Grade:choice:7A:7B:8A:8B:9A:9B}}"
subject: "{{Subject:choice:Chinese:English:Math:Geography:History}}"
created: '{{CreatedDate:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
modified: '{{ModifiedDate:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
tags:
- "{{Grade}}"
- "{{Subject}}"
- "{{Grade}}-{{Subject}}"
AutoNoteMover:
- disable
disabled rules:
- all
template-output: 060-Anki/{{Grade}}/{{Subject}}
template-input: title,body
template-should-replace: sometimes
template-should-create: open-tab
---
{{title}}
# {{Question:area}}
---
{{body}}
2. Improvements
{{title}}now works correctly with Chinese characters and generates files properly.- Can dynamically generate files into specific folders.
tagswithin YAML can now correctly generate list-style tags.- Time format can use
:but there's still a minor bug. - Provides clearer prompts upon file creation failure.
3. Custom Field Highlights
- Custom field format:
{{FieldName}} - Custom field types
- Text line type:
{{FieldName:text}}(:textcan be omitted); Specify default value:{{FieldName:text:DefaultValue}} - Text area type:
{{FieldName:area}},{{body}}defaults to area - Date/Time type:
{{FieldName:currentDate:Format}}, e.g.,'{{createdOn:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}' - Single-choice type:
{{FieldName:choice:Option1:Option2:Option3}} - Multi-choice type:
{{FieldName:multi:Option1:Option2:Option3}}
- Text line type:
- Read-only fields, title and path of the note being edited:
{{currentTitle}},{{currentPath}} - Add
|Hint textafter a custom field to generate hint text.
4. File Creation Guide (YAML Fields)
The way files are created based on a template is configured through the following fields in the YAML section; these fields are set in the template and will not be generated into the new note:
| Name | Value | Default | |
|---|---|---|---|
| template-id | Unique ID for the template | Lowercase version of the base name | |
| template-name | Name for the command | Base name of the file | |
| template-output | Directory to save the output<br>Save folder. Custom fields can be used to achieve dynamic folder operations, e.g.:Projects/{{project_select}} |
Recommended to use Inbox | |
| template-filename | Filename for the created note. Will have .md appended. Note: if you set a different filename, then make sure to use {{filename}} in the template-replacement strings if you want to link to the file. | {{title}} | |
| template-should-replace | Should the template write text back to the document? "always", "sometimes" = only if text is selected, "never"<br>Should data in the template-replacement format be written back to the note being edited? | "sometimes" | |
| template-replacement | A Mustache template to replace the selected text in the editor with. Can pass a list, which will appear as buttons in creator<br>Default format for writing back to the note being edited | [[{{title}}]]<sup>1</sup> | |
| template-input | If the command is called with some text selected, split it up using the plugin's split pattern, and put the values into those fields<br>Based on the 'Selection split' setting in the plugin options, populate data into {{title}} and {{body}} respectively | title,body<sup>2</sup> | |
| template-should-create | Should the template make and open a note? "none"=no note, "create"= create but don't open, "open"=create and open in current editor, "open-pane" = create and open in new pane, "open-tab" = open in new tab<br>How to open the file after creation | "open-tab" |
- README Error: The default value for template-replacement should be
[[{{title}}]]; the original webpage is incorrect. - The default split setting is
\s+-\s+, which means the separator string is <span class='keybs'>one or more spaces</span><span class='keybs'>-</span><span class='keybs'>one or more spaces</span>, splitting the text into two parts, which are then filled into{{title}}and{{body}}respectively.
- Field settings are separated by
:, when:is needed within the time format, prefix it with a backslash (\). - When generated, the last
:will have an extra backslash, which disappears automatically after saving. This can also be resolved by not using seconds. - Example:
'{{CreatedDate:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
5. 💡 Related Links
💡 Explanatory Article: https://jdev.tw/blog/8492/
✅ Obsidian Note From Template: https://github.com/mo-seph/obsidian-note-from-template
✅ [Obs#71] Multi-functional Template Plugin for Beginners: From Template: https://youtu.be/pzA66MwozsY
✅ Obs072-Step by Step From Template Note Creation Example Operation: https://youtu.be/CdxABcKYdts
💡 From Template Example Templates
✅ New Note Template: https://gist.github.com/emisjerry/0c0cd687aca93d5dcbab50c86b21db91
✅ New Book Template: https://gist.github.com/emisjerry/cf58c316b92a941a9025d31fd19c343b
6. Tutorial Video
##