Huuums / vscode-folder-templates

Create your own Component structure with a simple click.
MIT License
214 stars 33 forks source link

How to automatic combine the parent name. #112

Closed gapkukb closed 1 month ago

gapkukb commented 1 year ago

Usually, on the development's rules, if a component belongs to a module, we always combine the parent name to the component name's prefix.

For a module structure example: /module/ /module/moduleHeader.tsx /module/moduleBody.tsx /module/moduleFooter.tsx

It is unpleasant to repeatedly enter the prefix when use fttemplate to creates a new template

Is it possible to automatic combine the parent folder's name .

think about this

// .ftsetting.json :

{"combineParentName":true}

Huuums commented 1 year ago

I'm not sure I can follow.

Can you please give an example of what your template looks like and what you want it to look like to make it less cumbersome?

From what I understand you have a template like this

<FTName>
-- <FTName>Header.tsx
-- <FTName>Body.tsx
-- <FTName>Footer.tsx

But you would prefer

<FTName>
-- Header.tsx
-- Body.tsx
-- Footer.tsx
-- .ftsettings.json

// ftsettings.json
{"combineParentName":true}
gapkukb commented 1 year ago

Yes , No need to input the parent name and the file name will be auto-combine the foler name for prefix .

eg: I create a file 'header.tsx' in a folder named 'module' , then the file be created by extension with name 'moduleHeader'

in my work , i have to input the 'module' prefix when use the extension to create file . its a repeated work , I wanna looking for a simpler method to do that .

Thank you @Huuums

Huuums commented 1 month ago

Hi @gapkukb,

sorry for the super late info on this. I just now thought about implementing this and think I will not.

I understand that it's a bit tedious to enter the prefix but having something like an option can result in unwanted filenames. Especially if a template has nested directories.

Imagine this scenario:

<FTName>
-- Header.tsx
-- Body.tsx
-- Footer.tsx
-- AnotherDir
---- Testfile  // <-- what would this file be named? AnotherDirTestfile? Or <FTName>testfile
-- .ftsettings.json

In this case we cannot know where to append the prefix and where we shouldn't. so for now, unless you have another idea I would have to close this issue as I don't see a good way of implementation for this feature.