Configure once create everywhere.
- Install extension.
- Right click on any folder slecet
TemplaGen | Template Maker
.- U can also write
TemplaGen | Template Maker
in command plaettte. - Then select the path u want the template to be in.
- U can also write
- Select template u want for example
Flutter clean code
. - You're done.
-
- Clone repo on your local machine.
- Copy
templates
folder path totemplagen
->Templates Folder Path
in vscode settings.
-
- Create custom template then make pull request to share with community.
-
First
- Create Folder for templates anywhere on your device.
- Copy its path.
- Open vscode settings
- search for
templagen
- Look for
templatesFolderPath
and paste path in it.
-
Second
-
Create new Folder with any name you want.
-
Make
templagen.json
inside the Folder -
{ "name":"Flutter Bloc" "needSubDir": true, "subDirNameCase": "snakeCase", "foldersFilesNamesReplacer": [ { "case": "snakeCase", "nameToReplace": "key", "useSubDirName": true } ], "filesContentReplacer": [ { "case": "snakeCase", "nameToReplace": "<{key_sc}>", "useSubDirName": true }, { "case": "pascalCase", "nameToReplace": "<{key}>", "useSubDirName": true } ] }
-
Create any folders or files in the folder as you like.
-
-
Open vscode settings
-
search for
templagen
-
Dir Templates
edit in settings.json
-
for example:
{ "name": "Flutter Clean Code", "needSubDir": true, "subDirNameCase": "snakeCase", "dirs": { "data": [ "data_source", "models", "repository" ], "domain": [ "entities", "use_cases", "repository" ], "presentation": [ "components", "controller", "screens" ] } }
The output dir will be like
|- <subDirName>
|- data
| |- data_source
| |- models
| |- repository
|- domain
| |- entities
| |- use_cases
| |- repository
|- presentation
| |- components
| |- controller
| |- screens
-
is the name of template to be select when create template
-
JsonTemplate
name of the template -
FolderTemplate
overwrite folder name if not empty or whitespace
"name": "Flutter Clean Code"
- check wheter the template directories required subDir to created in or not.
- if
true
you'll be asked for subDir name. - if
false
the dirs will be created directly.
"needSubDir": true,
-
the name case you want
-
"needSubDir": "snakeCase",
-
define keys in dirs and files name to be replaced later
-
FolderTemplate
only -
{ "foldersFilesNamesReplacer": [ { "case": "snakeCase", "nameToReplace": "key", "useSubDirName": true } ] }
-
define keys inside files content to be replaced later
-
FolderTemplate
only -
{ "filesContentReplacer": [ { "case": "snakeCase", "nameToReplace": "<{key_sc}>", "useSubDirName": true }, { "case": "pascalCase", "nameToReplace": "<{key}>", "useSubDirName": true } ] }
- the dirs which will be created
JsonTemplate
- use to define yor template folder structure.
- U can use long path to define folders in folder like:
Fold/01/02/03/04
- This will create Directory
Fold
and create01
in it and create02
in01
and so on.
FolderTemplate
- From
v0.0.6
and above u can use this intemplagen.json
note that - Folders is the refrence.
- Any folder not in dirs will be added automatically when create the template.
- Any path defined in
dirs
but not in folder you will be asked whether to create its directory or remove paths fromdirs
intemplagen.json
. - You should make
folderTemplateAutoGenerateDirs
true from vscode settings.
"dirs": {
"data": [
"data_source",
"models",
"repository"
]
}
case
the case of the name to replacenameToReplace
with.nameToReplace
the key you define to be replaced.useSubDirName
choose wheter to use thesubDirName
or not- if set to
false
orneedSubDir
set to false you will be asked to enter a name to replace the key with
{
"case": "snakeCase",
"nameToReplace": "<{key_sc}>",
"useSubDirName": true
},
- The following docs of cases copied from change-case packages
camelCase
- Transform into a string with the separator denoted by the next word capitalized.
- test string |-> testString
capitalCase
- Transform into a space separated string with each word capitalized.
- test string |-> Test String
constantCase
- Transform into upper case string with an underscore between words.
- test string |-> TEST_STRING
dotCase
- Transform into a lower case string with a period between words.
- test string |-> test.string
headerCase
- Transform into a dash separated string of capitalized words.
- test string |-> Test-String
noCase
- Transform into a lower cased string with spaces between words.
- testString |-> test string
paramCase
- Transform into a lower cased string with dashes between words.
- test string |-> test-string
pascalCase
- Transform into a string of capitalized words without separators.
- test string |-> TestString
pathCase
- Transform into a lower case string with slashes between words.
- test string |-> test/string
sentenceCase
- Transform into a lower case with spaces between words, then capitalize the string.
- testString |-> Test string
snakeCase
- Transform into a lower case string with underscores between words.
- test string |-> test_string
- Json templates definitions.
- Path of folder that contain your templates.
- Auto generate dirs in templagen.json useful in case your want to save your folder templates on Github.
- When activated it will group templates instead of being separated in list.
- When
listShowTemplateNameAsPath
is set to true the text used to represent nested paths.
- When
templagen.json
name not exist show template name as the path it exist in.