From Template和先前介紹的QuickAdd+Templater方法相比,最大的區別是: 能在一個對話窗裡填好所有的資料,極大地增強了許多用戶體驗。
From Template能把所有的設定寫在模板檔裡,不用做其他設定或腳本撰寫,非常適合新手或沒有程式設計經驗的朋友們使用。
功能
- 由模板建立新筆記
- 由模板建立新筆記後,插入其內部鏈接到目前筆記
- 選取目前筆記文字填入模板欄位以產生筆記內容
模板建立
模板YAML設定
每個模板可在YAML區設定該模板建立筆記時的設定:
| YAML欄位 | 說明 | 範例 |
|---|---|---|
template-output | 新建筆記存放的資料夾 | 040-Highlights |
template-filename | 新建筆記的檔名,預設是 {{title}} | Book-{{title}} |
template-input | 選取目前筆記部份內容,以選項設定→【Selection Split】的正則運算式解析後填入{{template-input}}的欄位 | title,overview,body |
template-replacement | 選取目前筆記部份內容在建立筆記後,被取代成設定的值 | "[[{{title}}]] ![[{{title}}#^overview]]" |
template-should-replace | 上述取代的設定:
| "sometimes" |
template-should-create | 是否建立新筆記設定:
| "create" |
模板欄位
YAML區裡的模板欄位記得要加雙引號
內建欄位:
- title: 檔名
- body: 多列輸入
- templateResult: 模板展開後的內容
- currentTitle: 目前筆記檔名
- currentPath: 用模板產生筆記時的目前檔案路徑
模板欄位語法格式:
| 格式 | 說明 | 語法 | 範例 |
|---|---|---|---|
| text | 預設格式,單行輸入 | {{欄名:text:預設值:輸入說明}} | {{tags:text:Stephen Kin}} |
| area | 多行輸入 | {{欄名:area:輸入說明}} | {{overview:area:Your overview of this note}} |
| choice | 下拉選單(單選) | {{欄名:choice:Option1:Option2:...}} | {{tags:choice:專案筆記:文獻筆記:永久筆記}} |
| multi | 下拉選單(複選) | {{欄名:multi:Option1:Option2:...}} | {{tags:choice:obsidian:文獻筆記:永久筆記}} |
| currentDate | 系統日期 | {{欄名:currentDate:格式字串}} | {{CreatedDate:currentDate:yyyy-MM-dd HH-MM-ss}} |
操作重點
- 按〔Ctrl/Cmd+P〕在命令窗格裡找到要使用的模板
- 在欄位對話窗裡輸入或選擇
- 按〔Ctrl/Cmd+數字〕在欄位間移動
- 按〔Ctrl/Cmd+Enter〕提交對話窗資料
問題
- 空窗格按〔Ctrl/Cmd+P〕會找不到From模板檔。
- currentDate的時間格式不能用冒號
{{tags}}會被加到標籤清單窗格裡
相關鏈接
- mo-seph/obsidian-note-from-template: Simple plugin to create Notes from a template, and fill in fields defined there
- From Template sample: https://gist.github.com/emisjerry/ab601957e803cd296efaa12cb328bd17
教學影片
##
##
