Skip to content

Conversation

@Truongquangkhang
Copy link

@Truongquangkhang Truongquangkhang commented Jan 13, 2026

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

  • This MR adds support for custom templates in the model generation process, allowing consumers to inject additional generated code (e.g. filters, helper methods, DTOs) alongside default GORM Gen outputs.

User Case Description

A typical use case is generating:

  • {Model}Filter structs for dynamic query building

  • Common helper methods such as ToMap() for update operations or generic payload handling

image
  • result
image

Copy link

@propel-code-bot propel-code-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, ship it! 🚢

Details
Why was this auto-approved?
APPROVED: No issues detected.

@propel-code-bot
Copy link

Support generator custom model templates

Introduces a way to inject custom text/templates into generated model files. Adds storage for per-model template snippets and ensures they are rendered during both model and query code generation flows.

Key Changes

• Added new method Generator.ApplyCustomTemplateForModel to broadcast a template string across all tracked model metas
• Extended generate.QueryStructMeta with a CustomTemplates slice for template text storage
• Hooked template rendering into generateModelFile and generateSingleQueryFile so custom templates are executed before user-defined model methods

Affected Areas

generator.go
internal/generate/query.go

This summary was automatically generated by @propel-code-bot

@Truongquangkhang Truongquangkhang changed the title Gen model by custom template feat: gen model by custom template Jan 13, 2026
@Truongquangkhang Truongquangkhang changed the title feat: gen model by custom template [draft] gen model by custom template Jan 13, 2026
@Truongquangkhang Truongquangkhang changed the title [draft] gen model by custom template feat(gen): support custom templates for model generation Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants