vscode-folder-templates
vscode-folder-templates copied to clipboard
Add folder and template paths variables
It would be nice if there was a variable to add inside the template that contains the project template output path like imports.
example:
template_name:
file.js
inside_folder:
datasource.js
if I select the template path inside the project realtive path src/,
inside the datasource.js would be two options to relative paths to the project
[FTTemplatePath]template output root path ->src/template_name(orsrc)[FTRelativePath]template output file path ->src/template_name/inside_folder
so inside the datasource.js file I could use the relative path it has to import the file.js
import {foo, bar} from '[FTTemplatePath]/file.js';
Hey, sorry for taking a while to respond.
I think this is kind of tricky to implement.
for [FTTemplatePath] these things come to mind
src/<template_name>is an "absolute" notation that can resolve to very different things depending on the project configuration IIRC. This would be problematic.- resolving the path relative to the current file should be possible.
- This would result in you not getting
src/template_namebut./or././etc. depending on how deep you currently are in the template folder hierarchy
[FTRelativePath] doesn't make sense to me to be honest. It would be the same as a simple ./ or am I missing something here? Can you maybe give another example so I can understand better?
That would be nice to be implemented. In the file, we can have a path to file ../../../filename.ts, however, you can create it in a different folder in the solution and the path won't work. You need to change it manually to correct one, e.g. ../../filename.ts.
This would be useful. For example to define golang package name on each file using the name of the parent folder
project
|- foo
| |- bar.go
// bar.go
package foo
...
I'm not sure if this is the same thing or not, but I certainly think it would be useful to have a variable such as FTDirectory which points to the directory in which you are creating your template folder.
Similar to how VSCode snippets offers a TM_DIRECTORY variable.
This would allow me to include imports in my template files:
// Template folder
My Custom Template: // this is the template directory in .fttemplates
index.ts
other.ts
// in index.ts
import other from "<FTDirectory>/<FTName>/other";
Additional context: This would be useful in my case since we don't use relative imports (./) in our repo—paths are all relative to the project root.