{
	"ID": "20211226123004-dplpw0o",
	"Spec": "1",
	"Type": "NodeDocument",
	"Properties": {
		"id": "20211226123004-dplpw0o",
		"title": "範本片段",
		"updated": "20230820185634"
	},
	"Children": [
		{
			"ID": "20211226123024-6aiti1c",
			"Type": "NodeHeading",
			"HeadingLevel": 2,
			"Properties": {
				"id": "20211226123024-6aiti1c",
				"updated": "20211225221841"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "概述"
				}
			]
		},
		{
			"ID": "20211226123024-sv70lot",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-sv70lot",
				"updated": "20211228135113"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "範本片段用於在游標插入符位置快速插入之前設置好的文本內容，支援變量。範本片段使用 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": ".md"
				},
				{
					"Type": "NodeText",
					"Data": " 後綴文件，存放在工作空間 data/templates 文件夾下。"
				}
			]
		},
		{
			"ID": "20211226123024-eyagqur",
			"Type": "NodeHeading",
			"HeadingLevel": 2,
			"Properties": {
				"id": "20211226123024-eyagqur",
				"updated": "20211228104228"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "編寫範本"
				}
			]
		},
		{
			"ID": "20211226123024-pwx44l4",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-pwx44l4",
				"updated": "20211228140749"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "範本使用的是 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "a",
					"TextMarkAHref": "https://golang.org/pkg/text/template/",
					"TextMarkTextContent": "Go 編程語言的文字範本"
				},
				{
					"Type": "NodeText",
					"Data": "進行實作，如果你對此有了解的話，可以實作一些程式邏輯在裡面，比如比較邏輯、叠代邏輯等。另外，為了避免語法沖突，範本語法使用 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": ".action{action}"
				},
				{
					"Type": "NodeText",
					"Data": "（而不是 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "{{action}}"
				},
				{
					"Type": "NodeText",
					"Data": "）。"
				}
			]
		},
		{
			"ID": "20211226123024-eurqp4g",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-eurqp4g",
				"updated": "20230820185634"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "我們通過開原專案 Sprig (github repo: Masterminds/sprig) 內置了一些變量和函數來豐富範本。比如可通過 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": ".action{now | date \u0026quot;2006-01-02 15:04:05\u0026quot;}"
				},
				{
					"Type": "NodeText",
					"Data": "​ 來渲染當前時間，更多用法請參考 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "a",
					"TextMarkAHref": "http://masterminds.github.io/sprig/",
					"TextMarkTextContent": "Sprig 幫助文檔"
				},
				{
					"Type": "NodeText",
					"Data": "。"
				}
			]
		},
		{
			"ID": "20211226123024-46ipj4k",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-46ipj4k",
				"updated": "20211228124150"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "關於日期時間格式化有個細節需要"
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "tag",
					"TextMarkTextContent": "注意"
				},
				{
					"Type": "NodeText",
					"Data": "：Go 程式語言的格式化比較特殊：不是使用 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "yyyy-MM-dd HH:mm:ss"
				},
				{
					"Type": "NodeText",
					"Data": "，而是使用 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "2006-01-02 15:04:05"
				},
				{
					"Type": "NodeText",
					"Data": " 這個固定時間格式（"
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "a",
					"TextMarkAHref": "https://www.zhihu.com/question/366830553",
					"TextMarkTextContent": "知乎討論"
				},
				{
					"Type": "NodeText",
					"Data": "）。"
				}
			]
		},
		{
			"ID": "20211226123024-hcvjosa",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-hcvjosa",
				"updated": "20211228135329"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "除了 Sprig 內置的變量和函數，還支援如下變量和函數："
				}
			]
		},
		{
			"ID": "20211226123024-pjvw31z",
			"Type": "NodeList",
			"ListData": {},
			"Properties": {
				"id": "20211226123024-pjvw31z",
				"updated": "20220605170337"
			},
			"Children": [
				{
					"ID": "20211226123024-jck7280",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-jck7280",
						"updated": "20211228104250"
					},
					"Children": [
						{
							"ID": "20211226123024-ezex4bu",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-ezex4bu",
								"updated": "20211228104250"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "title"
								},
								{
									"Type": "NodeText",
									"Data": "：該變量用於插入當前文檔名。比如範本內容為 "
								},
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "# .action{.title}"
								},
								{
									"Type": "NodeText",
									"Data": "，則調用後會以一級標題語法插入到當前文檔內容中"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-7oozkfr",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-7oozkfr"
					},
					"Children": [
						{
							"ID": "20211226123024-vy2z5oq",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-vy2z5oq"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "id"
								},
								{
									"Type": "NodeText",
									"Data": "：該變量用於插入當前文檔 ID"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-l1jz2w8",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-l1jz2w8"
					},
					"Children": [
						{
							"ID": "20211226123024-xx9l8ku",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-xx9l8ku"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "name"
								},
								{
									"Type": "NodeText",
									"Data": "：該變量用於插入當前文檔命名"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-jdmxqwy",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-jdmxqwy",
						"updated": "20220605170337"
					},
					"Children": [
						{
							"ID": "20211226123024-yfk0zfn",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-yfk0zfn",
								"updated": "20220605170337"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "alias"
								},
								{
									"Type": "NodeText",
									"Data": "：該變量用於插入當前文檔別名"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-e42d7xq",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-e42d7xq",
						"updated": "20211228141606"
					},
					"Children": [
						{
							"ID": "20211226123024-vxjdsno",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-vxjdsno",
								"updated": "20211228141606"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "queryBlocks"
								},
								{
									"Type": "NodeText",
									"Data": "：該函數用於查詢資料庫，返回值為 blocks 列表，參數為 SQL 語句："
								},
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": ".action{sql \"SELECT * FROM blocks LIMIT 7\"}"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-69kddle",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-69kddle",
						"updated": "20211228141602"
					},
					"Children": [
						{
							"ID": "20211226123024-4qwyf3w",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-4qwyf3w",
								"updated": "20211228141602"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "querySpans"
								},
								{
									"Type": "NodeText",
									"Data": "：該函數用於查詢資料庫，返回值為 spans 列表，參數為 SQL 語句："
								},
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": ".action{sql \"SELECT * FROM spans LIMIT 7\"}"
								}
							]
						}
					]
				},
				{
					"ID": "20211226123024-kca62r8",
					"Type": "NodeListItem",
					"ListData": {
						"BulletChar": 42,
						"Marker": "Kg=="
					},
					"Properties": {
						"id": "20211226123024-kca62r8"
					},
					"Children": [
						{
							"ID": "20211226123024-8esfka7",
							"Type": "NodeParagraph",
							"Properties": {
								"id": "20211226123024-8esfka7"
							},
							"Children": [
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "parseTime"
								},
								{
									"Type": "NodeText",
									"Data": "：該函數用於將時間格式的字符串解析為 "
								},
								{
									"Type": "NodeTextMark",
									"TextMarkType": "code",
									"TextMarkTextContent": "time.Time"
								},
								{
									"Type": "NodeText",
									"Data": " 類型，以便使用更多格式化方法渲染該時間"
								}
							]
						}
					]
				}
			]
		},
		{
			"ID": "20211226123024-5rk6w30",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-5rk6w30",
				"updated": "20211228134953"
			},
			"Children": [
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "queryBlocks"
				},
				{
					"Type": "NodeText",
					"Data": " 和 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "querySpans"
				},
				{
					"Type": "NodeText",
					"Data": " 支援類似 SQL 預編譯語句的變參列表，方便傳入參數："
				}
			]
		},
		{
			"ID": "20211226123024-sw1k190",
			"Type": "NodeCodeBlock",
			"IsFencedCodeBlock": true,
			"Properties": {
				"id": "20211226123024-sw1k190",
				"updated": "20211225221841"
			},
			"Children": [
				{
					"Type": "NodeCodeBlockFenceOpenMarker",
					"Data": "```"
				},
				{
					"Type": "NodeCodeBlockFenceInfoMarker"
				},
				{
					"ID": "20220307092237-mawslux",
					"Type": "NodeCodeBlockCode",
					"Data": ".action{$today := now | date \"20060102150405\"}\n.action{$blocks :=queryBlocks \"SELECT * FROM blocks WHERE content LIKE '?' AND updated \u003e '?' LIMIT ?\" \"%foo%\" $today \"3\"}\n",
					"Properties": {
						"id": "20220307092237-mawslux"
					}
				},
				{
					"Type": "NodeCodeBlockFenceCloseMarker",
					"Data": "```"
				}
			]
		},
		{
			"ID": "20211226123024-3wiifft",
			"Type": "NodeHeading",
			"HeadingLevel": 2,
			"Properties": {
				"id": "20211226123024-3wiifft",
				"updated": "20211228104256"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "調用範本"
				}
			]
		},
		{
			"ID": "20211226123024-wtjurrr",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-wtjurrr",
				"updated": "20211228104309"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "在游標插入符位置，通過 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "/"
				},
				{
					"Type": "NodeText",
					"Data": " 選擇範本來觸發範本搜索，找到需要插入的範本後Enter即可。"
				}
			]
		},
		{
			"ID": "20211226123024-yrgnp4o",
			"Type": "NodeHeading",
			"HeadingLevel": 2,
			"Properties": {
				"id": "20211226123024-yrgnp4o",
				"updated": "20211225221841"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "一個示例"
				}
			]
		},
		{
			"ID": "20211226123024-s56q5uh",
			"Type": "NodeCodeBlock",
			"IsFencedCodeBlock": true,
			"Properties": {
				"id": "20211226123024-s56q5uh",
				"updated": "20211225221841"
			},
			"Children": [
				{
					"Type": "NodeCodeBlockFenceOpenMarker",
					"Data": "```"
				},
				{
					"Type": "NodeCodeBlockFenceInfoMarker",
					"CodeBlockInfo": "cGxhaW50ZXh0"
				},
				{
					"ID": "20220307092237-cf60m2o",
					"Type": "NodeCodeBlockCode",
					"Data": ".action{$before := (div (now.Sub (toDate \"2006-01-02\" \"2020-02-19\")).Hours 24)}\n\n.action{$after := (div ((toDate \"2006-01-02\" \"2048-02-19\").Sub now).Hours 24)}\n今天是 `.action{now | date \"2006-01-02\"}`。\n\n* 距離 `2020-02-19` 已經過去 `.action{$before}` 天\n* 距離 `2048-02-19` 還剩 `.action{$after}` 天\n",
					"Properties": {
						"id": "20220307092237-cf60m2o"
					}
				},
				{
					"Type": "NodeCodeBlockFenceCloseMarker",
					"Data": "```"
				}
			]
		},
		{
			"ID": "20211226123024-ddwrf29",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-ddwrf29",
				"updated": "20211225221841"
			},
			"Children": [
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "$before"
				},
				{
					"Type": "NodeText",
					"Data": " 和 "
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "code",
					"TextMarkTextContent": "$after"
				},
				{
					"Type": "NodeText",
					"Data": " 定義了兩個變量，分別記錄當前日期距離 2020 年和 2048 年的天數。"
				}
			]
		},
		{
			"ID": "20211226123024-4ihq4sa",
			"Type": "NodeHeading",
			"HeadingLevel": 2,
			"Properties": {
				"id": "20211226123024-4ihq4sa",
				"updated": "20221114173626"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "上架社區集市"
				}
			]
		},
		{
			"ID": "20221114173549-5ie5uaj",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20221114173549-5ie5uaj",
				"updated": "20230820184235"
			},
			"Children": [
				{
					"Type": "NodeText",
					"Data": "請參考"
				},
				{
					"Type": "NodeTextMark",
					"TextMarkType": "a",
					"TextMarkAHref": "https://b3log.org/siyuan/community.html",
					"TextMarkTextContent": "社區集市倉庫"
				},
				{
					"Type": "NodeText",
					"Data": "。"
				}
			]
		},
		{
			"ID": "20211226123024-c71b8tn",
			"Type": "NodeParagraph",
			"Properties": {
				"id": "20211226123024-c71b8tn",
				"updated": "20211226123024"
			}
		}
	]
}