Skip to content

"name" property in custom template #118

@jitiendran

Description

@jitiendran

Description

Introduce name property in customTemplate to even enhances the customTemplate feature where the user need to have separate component TemplateName and the only purpose of the TemplateName component is to provide templates which takes up space.

So the name property provides the user with two option dynamic and user defined name.

  • dynamic - this takes the component name from the template path provided in config and replaces it with the name provided while generation.

    For example:

    {
        "customTemplate": {
            "name": "dynamic",
            "component": "../HeroAction.tsx",
            "style": "../HeroAction.css",
            "test": "../HeroAction.test.tsx",
            "story": "../HeroAction.stories.tsx"
        }
    }

    Note: Here the component name used in the templates is HeroAction based on the general practice of naming the component file the same as component function, so HeroAction will be replaced with name provided while generation.

  • Custom Name - this can be used when your project doesn't follow the practice of naming the component file the same as component function. So the component name provided for name property will be replaced with the component name provided in the generation.

    For example:

    {
        "customTemplate": {
            "name": "Hero",
            "component": "../HeroAction.tsx",
            "style": "../HeroAction.css",
            "test": "../HeroAction.test.tsx",
            "story": "../HeroAction.stories.tsx"
        }
    }

    Here the HeroAction.tsx file will have component function named Hero, so component name Hero will be replaced by the component name provided while generation.

Suggested solution

This can be achieved by introducing name property in customTemplate

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestp3-enhancementEnhancement under consideration

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions