From 6da38f5721b21947b29742509b8055249ef7142d Mon Sep 17 00:00:00 2001 From: jolheiser Date: Sat, 2 Jan 2021 21:26:46 -0600 Subject: [PATCH 1/2] [skip ci] Explain .tmplkeep Signed-off-by: jolheiser --- .gitea/pull_request_template.md | 6 ++++++ DOCS.md | 11 ++++++++++- docs.go | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .gitea/pull_request_template.md diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md new file mode 100644 index 0000000..f4def42 --- /dev/null +++ b/.gitea/pull_request_template.md @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/DOCS.md b/DOCS.md index 638b13b..7a3f2b9 100644 --- a/DOCS.md +++ b/DOCS.md @@ -119,4 +119,13 @@ I realize that many users will be using GitHub, and most will likely still be us 1. The simplest solution is to make a copy of your `registry.toml` (default: `~/.tmpl/registry.toml`). * Once in the new location, you will need to use `tmpl restore`. -2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step. \ No newline at end of file +2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step. + +## `.tmplkeep` + +Perhaps you are familiar with `.gitkeep` and its unofficial status in git. Git does not like empty directories, so usually +a `.gitkeep` (or just `.keep`) file is added to retain the directory while keeping it effectively empty. + +tmpl instead uses `.tmplkeep` files for this purpose. The difference is, tmpl will **not** create the `.tmplkeep` file +when the template is executed. This allows you to set up directory structures (for staging, examples, etc.) that +will *actually* be empty after execution. \ No newline at end of file diff --git a/docs.go b/docs.go index 3ca29f5..aa13bf6 100644 --- a/docs.go +++ b/docs.go @@ -28,7 +28,7 @@ func main() { md = md[strings.Index(md, "#"):] // CLI is using real default instead of DefaultText - md = regexp.MustCompile(`[\/\w]+\.tmpl`).ReplaceAllString(md, "~/.tmpl") + md = regexp.MustCompile(`[\/\\:\w]+\.tmpl`).ReplaceAllString(md, "~/.tmpl") if _, err := fi.WriteString(md); err != nil { panic(err) -- 2.41.0 From c173eee38c48424abe470b8ed2b9ef0dd48f65f8 Mon Sep 17 00:00:00 2001 From: John Olheiser Date: Sun, 3 Jan 2021 11:29:37 +0800 Subject: [PATCH 2/2] Explain .tmplkeep (#17) Co-authored-by: jolheiser Reviewed-on: https://gitea.com/jolheiser/tmpl/pulls/17 Co-authored-by: John Olheiser Co-committed-by: John Olheiser --- .gitea/pull_request_template.md | 6 ++++++ DOCS.md | 11 ++++++++++- docs.go | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .gitea/pull_request_template.md diff --git a/.gitea/pull_request_template.md b/.gitea/pull_request_template.md new file mode 100644 index 0000000..f4def42 --- /dev/null +++ b/.gitea/pull_request_template.md @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/DOCS.md b/DOCS.md index 638b13b..7a3f2b9 100644 --- a/DOCS.md +++ b/DOCS.md @@ -119,4 +119,13 @@ I realize that many users will be using GitHub, and most will likely still be us 1. The simplest solution is to make a copy of your `registry.toml` (default: `~/.tmpl/registry.toml`). * Once in the new location, you will need to use `tmpl restore`. -2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step. \ No newline at end of file +2. Alternatively, you can copy/paste the entire registry (default: `~/.tmpl`) and skip the restore step. + +## `.tmplkeep` + +Perhaps you are familiar with `.gitkeep` and its unofficial status in git. Git does not like empty directories, so usually +a `.gitkeep` (or just `.keep`) file is added to retain the directory while keeping it effectively empty. + +tmpl instead uses `.tmplkeep` files for this purpose. The difference is, tmpl will **not** create the `.tmplkeep` file +when the template is executed. This allows you to set up directory structures (for staging, examples, etc.) that +will *actually* be empty after execution. \ No newline at end of file diff --git a/docs.go b/docs.go index 3ca29f5..aa13bf6 100644 --- a/docs.go +++ b/docs.go @@ -28,7 +28,7 @@ func main() { md = md[strings.Index(md, "#"):] // CLI is using real default instead of DefaultText - md = regexp.MustCompile(`[\/\w]+\.tmpl`).ReplaceAllString(md, "~/.tmpl") + md = regexp.MustCompile(`[\/\\:\w]+\.tmpl`).ReplaceAllString(md, "~/.tmpl") if _, err := fi.WriteString(md); err != nil { panic(err) -- 2.41.0