Create code folders faster for any language!
dtl def ReactComponent ComponentInProject # saves template named "ReactComponent" based on ComponentInProject folder
dtl new ReactComponent MyComponent # generates lot of files based on "ReactComponent" template
dtl ren MyComponent SuperComponent # rename files and occurrences of "MyComponent" in any letter case in files
dtl dup MyComponent SimilarComponent # creates copy of "MyComponent" and renames it, but not in place like `ren` command
This utils is designed to help programmers, when they using component oriented architecture. For us components is set of files, that has boilerplate code. The main difference between one component and another is the name of it. So to create new component we need just to copy code of old component and replace it name EVERYWHERE (filenames, content of files).
DTL simplifies process of copying and renaming of files for you ❤️.
Create new template and store it to "DirectoryTemplates" folder. All occurrences of <name>
in any letter case will be replaced to appropriate variant it template syntax.
Syntax:
dtl def <templateName> <name> [files..]
Creates new template from given files. If no files given looks for folder with <name> to use it as base of template
* templateName - The name of result template. If no files provided, also directory to be used as template base.
* name - Name in pascal case to be replaced in given files in all available DTL cases.
* files- Files to be added to template, usually you will add a single folder. All given files will be placed into template root.
Examples:
dtl def TemplateName ComponentFolder # No files, so name is ComponentFolder and looking for same name folder
dtl def TemplateName ComponentName index.ts ComponentName.tsx ComponentName.module.scss # Example with files
Generates files by template name. Template could have multiple files at the root or complex folder structure. This command will replace any occurrences of name.
Syntax:
dtl new <templateName> <folderName>
Creates directory with template contents
* templateName - Name of template
* folderName - Name of folder to be created
Examples:
dtl new TemplateName MyComponent # Creates component by template. All occurrences on name will be replaced to "MyComponent"
List all available templates. Also prints place, where templates are stored.
Examples:
dtl list
Renames component recursively. Target or renaming could be any folder. You could copy some folder and rename it with this command, so you don't need to register templates for fast tasks.
Syntax:
dtl ren <name> <newName> [files..]
Renames filenames and occurrences in files from <name> to <newName> in any letter case.
* name - The current name of entity in pascal case. This name will be replaced, no matter in what letter case it will be found. If no files provided, also directory to be used as template base.
* newName - Value in pascal case to be set instead on <name>. This value will be converted to matching letter case.
* files - Files to be using while renaming, usually you will add a single folder.
Examples:
dtl ren OldComponent NewComponent # Renames OldComponent to NewComponent
dtl ren OldName NewName SomeFolder # Renames all occurrences of OldName to NewName in SomeFolder
Creates copy of component and renames it. This command allows you not to create templates for components that you don't gonna copy often.
Syntax:
dtl dup <name> <newName> [files..]
Copy files and renames filenames and occurrences in files from <name> to <newName> in any letter case.
* name - The current name of entity in pascal case. This name will be replaced, no matter in what letter case it will be found. If no files provided, also directory to be used as template base.
* newName - Value in pascal case to be set instead on <name>. This value will be converted to matching letter case.
* files - Files to be using while renaming, usually you will add a single folder.
Examples:
dtl ren OldComponent NewComponent # Creates copy of OldComponent with name NewComponent
dtl ren OldComponent NewComponent OldComponent.tsx # Creates file NewComponent.tsx near to OldComponent.tsx
Templates provide few special statements. All of them can be used:
- Inside of files.
- In file/directory names.
Any template can consist any count of folders & files.
All statements are wrapped by --
. Here they are:
- Case sensitive
name
. Second param of termnew
command:
--Name-- // Case as defined
--name-- // Lower case
--NAME-- // Upper case
--na-me-- // Kebab case
- Current
datetime
:
--DateTime--
From-Use
statement. Paste files from other templates:
-- From TemplateName: Use ./rel/path/to/file.js; --