A powerful VSCode extension that streamlines code generation through customizable templates and JSON-driven content generation. Perfect for developers looking to automate repetitive coding tasks and maintain consistent code structure across projects.
- π― Template Creation: Build reusable templates from existing code structures
- π Code Generation: Generate code from templates using JSON data input
- π Smart Text Formatting: Support multiple text cases (kebab, camel, pascal, snake)
- π¨ Dynamic Content Generation: Auto-generate model properties and HTML elements based on JSON data types
- π Targeted Updates: Insert code at specific locations using markers
- π Structure Preservation: Maintains directory structure when creating templates
- Launch Visual Studio Code
- Open the Extensions view (
Ctrl+Shift+XorCmd+Shift+X) - Search for "IT-Tom Generate Code"
- Click Install
-
New Template:
- Select file(s)/folder(s) in the explorer
- Right-click β "IT-Tom Build Template"
- Enter project name
- Template is created in
_projectname_templatefolder
-
Update Existing Template:
- Select text to use as marker
- Right-click β "IT-Tom Set Key For Update"
- Choose template to update
- Using JSON:
- Select JSON text (optional)
- Right-click β "IT-Tom Generate Code"
- Enter JSON if not selected
- Select template
- Fill in placeholders
pathTemplate: Source file path in template directorypathGenerate: Target path for new file generation (supports placeholders)pathUpdate: Path to existing file to modifyactionType: "create" or "update"updateConfigs: Array of update rules containing:type: Position to insert ("before"/"after" the key)key: Marker text in filecontentInsert: Content to insert (supports placeholders)isCheckExistNotUpdate: Prevents duplicate content if true
Defines file handling rules. Each entry can be either a "create" or "update" configuration:
{
"pathTemplate": "src/models/user.ts", // Source template file path
"pathGenerate": "src/models/@{camel-area}/@{camel-model}.ts", // Target generation path
"actionType": "create" // Specifies file creation
}{
"pathUpdate": "src/app.module.ts", // Target file to update
"actionType": "update", // Specifies file update
"updateConfigs": [{
"type": "before", // Insert position: "before" or "after"
"key": "// <insert-modules-here>", // Marker for insertion point
"contentInsert": "import { @{pascal-model}Module } from './@{kebab-model}/@{kebab-model}.module';",
"isCheckExistNotUpdate": true // Skip if content exists
}]
}-
@fieldName: The field name of the previously entered JSON object model. -
display: A mandatory branch that must be declared, containing sub-branches used for rendering.display.DisplayModel: As shown in the example,DisplayModelcan be (formHtmlInteger, form, formInteger, etc.).
-
Structure of
DisplayModel:nameUnique: A unique name within theDisplayModel[]array, used whenconvertis declared as @{display.DisplayModel}.dataType: SupportsInteger,Float,String,Boolean,Date, andDateTime.convert: The content to be converted to or selected (@{display.DisplayModel}).followBySelect: Used to track the selection of @{display.DisplayModel} as desired.
Example: Defines code generation patterns for different data types:
{
"__comment": "Key example @{<<fieldName>>}",
"display": {
"formHtml": [
{
"dataType": "String",
"convert": "@{fieldName} render for string"
},
{
"dataType": "Integer",
"convert": "@{display.formHtmlInteger}"
},
{
"dataType": "Boolean",
"convert": ""
},
{
"dataType": "DateTime",
"convert": "public @{fieldName}: Date;"
}
],
"formHtmlInteger": [
{
"nameUnique": "SelectList",
"dataType": "Integer",
"convert": " <tr>\n <th scope=\"row\" class=\"th-bg\">@{lable-fieldName}</th>\n <td>\n <app-selectbox useAllOptionName=\"Select\" [options]=\"@{camel-fieldName}List\" dataKey=\"@{camel-fieldName}Value\" displayKey=\"@{camel-fieldName}Text\" formControlName=\"@{camel-fieldName}\" class=\"flex-fill\" [class.valid-error]=\"checkIsInvalid('@{camel-fieldName}')\"></app-selectbox>\n </td>\n </tr>"
},
{
"nameUnique": "Numberic",
"dataType": "Integer",
"convert": " <tr>\n <th scope=\"row\" class=\"th-bg\">@{lable-fieldName}</th>\n <td>\n <app-input-text formControlName=\"@{camel-fieldName}\" [isInvalid]=\"checkIsInvalid('@{camel-fieldName}')\" inputFormat=\"numberOnly\"></app-input-text>\n </td>\n </tr>"
}
],
"form": [
{
"dataType": "String",
"convert": "public @{fieldName}: string;"
},
{
"dataType": "Integer",
"convert": "@{display.formInteger}",
"followBySelect": "formHtml"
},
{
"dataType": "Boolean",
"convert": "public @{fieldName}: boolean;"
},
{
"dataType": "Object",
"convert": "public @{fieldName}: any;"
},
{
"dataType": "Array",
"convert": "public @{fieldName}: any[];"
},
{
"dataType": "DateTime",
"convert": "public @{fieldName}: Date;"
}
],
"formInteger": [
{
"nameUnique": "SelectList",
"dataType": "Integer",
"convert": " @Input() select@{pascal-fieldName}: number;\n @Input() @{camel-fieldName}List: any[];"
}
]
}
}Use in templates for dynamic code generation:
export class @{pascal-model} {
@{display.model-for} // Generates properties from JSON
constructor() {
// Constructor logic
}
}Input text supports the following formats: "user profile", "user-profile", "user_profile", and "userProfile".
| Format Tag | Input Text Example | Output | Description |
|---|---|---|---|
@{kebab-text} |
userProfile | user-profile |
Lowercase with hyphens |
@{camel-text} |
user profile | userProfile |
camelCase formatting |
@{pascal-text} |
user-profile | UserProfile |
PascalCase formatting |
@{snake-text} |
user profile | user_profile |
Lowercase with underscores |
@{upper-text} |
user profile | USER_PROFILE |
Uppercase without separators |
@{lower-text} |
user profile | user_profile |
Lowercase without separators |
@{label-text} |
user profile | User Profile |
Lable case formatting |
- Purpose: Generate new files
- Configuration: Uses
pathTemplateandpathGenerate - Features: Supports placeholder substitution
- Purpose: Modify existing files
- Configuration: Uses
pathUpdateandupdateConfigs - Features:
- Insert before/after markers
- Optional duplicate check (
isCheckExistNotUpdate)
- Visual Studio Code 1.97.0 or higher
- Workspace with write permissions
Found a bug or have a suggestion? Please report it on our GitHub repository.
- Initial release
- Template generation system
- JSON-based code generation
- Multiple text format support
- Dynamic content generation
We welcome contributions! Please feel free to submit pull requests.
This extension is licensed under the MIT License.