tarantool / tarantool/tt

templates: Add ability to ignore file depending on var

Open
#701 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature teamE
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:

https://github.com/tarantool/tt/blob/550b7b04f996d10a3337a08ccef3f64ca9e870c6/cli/create/internal/steps/render_template.go#L35-L44

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.