templates: Add ability to ignore file depending on var
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 113
- Forks
- 18
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 23
Description
Because you've implemented templates by go template, we can use variables not only simple substitution but all abilities from go templates. For example if statements:
{{ if eq .expirationd "y" -}}
expirationd.init_module()
{{ end -}}
It's usefull to choose features from template. And that's great feature.
But we need to have the same ability with files themselves. To ignore them at all.
As suggest you can add only a few line here:
Somethink like that:
If file name after rendering is empty ".tt.template", we just ignore it
// Render file name.
newFileName, err := templateCtx.Engine.RenderText(filePath, templateCtx.Vars)
if err != nil {
return fmt.Errorf("failed file name processing %s: %s", filePath, err)
}
+ if newFileName == ".tt.template" {
+ continue;
+ }
if newFileName != filePath {
if err = os.Rename(filePath, newFileName); err != nil {
return fmt.Errorf("error renaming %s to %s: %s", filePath, newFileName, err)
}
}
Especially need to ignore directories
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cli/create/internal/steps/render_template.go at the file-name rendering and rename logic linked in the issue. Trace how rendered paths are handled for files and directories, then verify that paths rendering to .tt.template are ignored, including the requested directory case. Done means conditional template output can omit those paths without affecting other rendered files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100