Obsidian Note From Template(簡稱From Template)是我最常用的模板外掛(Templater外掛則只要用來撰寫腳本),最近兩周終於釋出了更新版本,在新版本裡解決了原有的問題,並且提供了更放的動態功能,非常值得朋友們試用。
1. 功能展示
```button
name 建立新筆記
type command
action From Template: from-template-Note
color purple
```
^button-newNote
```button
name 建立新書籍
type command
action From Template: from-template-Book2
color green
```
^button-newBook2
```button
name 開啟新筆記模板
type link
action obsidian://advanced-uri?vault=jerry-notes&filepath=011-From-Template/From-Template-Note
color purple
```
^button-openNewNoteTemplate
```button
name 開啟新書籍模板
type link
action obsidian://advanced-uri?vault=jerry-notes&filepath=011-From-Template/From-Template-Book2
color green
```
^button-openNewBook2Template
---
aliases:
grade: "{{年級:choice:7A:7B:8A:8B:9A:9B}}"
subject: "{{科目:choice:國文:英文:數學:地理:歷史}}"
created: '{{建檔日期:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
modified: '{{建檔日期:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
tags:
- "{{年級}}"
- "{{科目}}"
- "{{年級}}-{{科目}}"
AutoNoteMover:
- disable
disabled rules:
- all
template-output: 060-Anki/{{年級}}/{{科目}}
template-input: title,body
template-should-replace: sometimes
template-should-create: open-tab
---
{{title}}
# {{問題:area}}
---
{{body}}
2. 改進
{{title}}已能正常使用中文,能正確產生檔案- 能動態產生到特定資料夾
- YAML內的
tags已能正確產生表列式的標籤 - 時間格式能使用
:但尚有小Bug - 建檔失敗會有更清楚的提示
3. 自訂欄位重點
- 自訂欄位格式:
{{欄位}} - 自訂欄位類型
- 文字行型態:
{{欄位:text}}(可省略:text);指定預設值:{{欄位:text:預設值}} - 文字框型態:
{{欄位:area}},{{body}}預設是area - 日期時間型態:
{{欄位:currentDate:格式}},如:'{{createdOn:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}' - 單選型態:`{{欄位:choice:選項1:選項2:選項3}}
- 複選型態:`{{欄位:multi:選項1:選項2:選項3}}
- 文字行型態:
- 唯讀欄位,編輯中筆記的標題與其路徑:
{{currentTitle}}、{{currentPath}} - 自訂欄位後方可加入
|提示文字以產生提示文字
4. 建檔指引(YAML欄位)
依據模板而建立的檔案產生的方式是透過YAML區裡的下列欄位來設定的;這些欄位是設定在模板裡,不會產生到新筆記:
| 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>存檔資料夾。能使用自訂欄位以達成動態資料夾之操作,例如:Projects/{{project_select}} |
建議使用 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>是否要把template-replacement格式的資料寫回編輯中的筆記? | "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>回寫至編輯中筆記的預設格式 | [[{{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>依外掛選項裡的Selection split設定,分別將資料填入{{title}}與{{body}} | 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>檔案產生完畢後如何開啟 | "open-tab" |
額外說明
- README錯誤:template-replacement的預設值應該是
[[{{title}}]]才對,原網頁有錯 - 預設的分隔設定是
\s+-\s+表示分隔字串是<span class='keybs'>一或多個空白</span><span class='keybs'>-</span><span class='keybs'>一或多個空白</span>分隔成兩段字串,分別填入{{title}}與{{body}}
時間格式如何指定?
- 欄位設定以
:分隔,而時間裡需要:時在前方加上反斜線(\) - 產生時最後一個
:會多出反斜線,儲存後自動消失。不使用秒數亦可解決 - 範例:
'{{建檔日期:currentDate:"yyyy-MM-dd HH\:mm\:ss"}}'
5. 💡 相關鏈接
💡 解說文章: https://jdev.tw/blog/8492/
✅ Obsidian Note From Template: https://github.com/mo-seph/obsidian-note-from-template
✅ [Obs#71] 新手適用的多功能模板外掛:From Template: https://youtu.be/pzA66MwozsY
✅ Obs072-Step by Step From Template建立筆記實例操作: https://youtu.be/CdxABcKYdts
💡 From Template模板範例
✅ 新筆記模板: https://gist.github.com/emisjerry/0c0cd687aca93d5dcbab50c86b21db91
✅ 新書籍模板: https://gist.github.com/emisjerry/cf58c316b92a941a9025d31fd19c343b
6. 教學影片
##