Explain .tmplkeep (#17)

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: https://gitea.com/jolheiser/tmpl/pulls/17
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-committed-by: John Olheiser <john.olheiser@gmail.com>
pull/18/head
John Olheiser 2021-01-03 11:29:37 +08:00
parent c497431a52
commit c173eee38c
3 changed files with 17 additions and 2 deletions

View File

@ -0,0 +1,6 @@
<!--
1. Did you add documentation?
2. Did you add tests?
3. Do you need to re-run formatting?
4. Do you need to re-run docs.go?
-->

11
DOCS.md
View File

@ -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.
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.

View File

@ -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)