Skip to content

[7359] Add support for alternate Freemarker suffixes besides .ftl (.ftlh .ftlx) #4893

Draft
jvega190 wants to merge 4 commits into
craftercms:developfrom
jvega190:feature/7359
Draft

[7359] Add support for alternate Freemarker suffixes besides .ftl (.ftlh .ftlx) #4893
jvega190 wants to merge 4 commits into
craftercms:developfrom
jvega190:feature/7359

Conversation

@jvega190

@jvega190 jvega190 commented Jun 16, 2026

Copy link
Copy Markdown
Member

craftercms/craftercms#7359

Summary by CodeRabbit

  • New Features
    • Enhanced template file creation with extension selection. Users can now choose from available template file extensions when creating new template files via a dedicated dropdown selector.

@jvega190

Copy link
Copy Markdown
Member Author

Depends on craftercms/craftercms#8737

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@jvega190, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 12 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b422510b-4fa8-4854-a975-a863e637548b

📥 Commits

Reviewing files that changed from the base of the PR and between b381d7f and 9a4d4c8.

📒 Files selected for processing (3)
  • ui/app/src/components/CreateFileDialog/CreateFileDialogContainer.tsx
  • ui/app/src/components/CreateFileDialog/utils.ts
  • ui/app/src/utils/path.ts

Walkthrough

Adds a file-extension dropdown to CreateFileDialog for template files. A TEMPLATE_EXTENSIONS constant and TemplateExtension type are introduced in utils.ts. Path utilities pickExtensionForItemType and getFileNameWithExtensionForItemType gain an optional extension override parameter. CreateFileDialogContainer adds extension state, a getFileName helper, an extensionField dropdown, and a conditional flex-row layout for template creation.

Changes

Template File Extension Selector

Layer / File(s) Summary
Extension constants and path utility update
ui/app/src/components/CreateFileDialog/utils.ts, ui/app/src/utils/path.ts
Introduces TEMPLATE_EXTENSIONS, TemplateExtension, and DEFAULT_TEMPLATE_EXTENSION in utils.ts. Updates pickExtensionForItemType to accept an optional extension override (normalizing leading ., keeping groovy for controllers and name-derived extension for assets) and getFileNameWithExtensionForItemType to forward the override.
Dialog extension state, filename derivation, and UI
ui/app/src/components/CreateFileDialog/CreateFileDialogContainer.tsx
Adds extension local state, a getFileName helper that appends the chosen extension for templates, onExtensionChange to reset existence-check state, an extensionField MUI Select dropdown populated from TEMPLATE_EXTENSIONS, propagation of getFileName into validation and confirm flows, updated onCreated mode derivation from selected extension, and a conditional flex-row rendering path for templates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only provides a GitHub issue link without content. While the link is relevant, it doesn't follow the template structure or provide substantive explanation of what's in the PR. Expand the description to include the ticket reference and a clear explanation of the changes, why they're needed, and how they address the issue, following the provided template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding support for alternate Freemarker template suffixes (.ftlh, .ftlx) besides .ftl, which aligns with the implementation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/src/components/CreateFileDialog/utils.ts`:
- Around line 39-41: The TEMPLATE_EXTENSIONS array lacks the `as const`
modifier, causing TypeScript to infer the type as a generic string array rather
than preserving the literal types of the individual elements. This causes the
TemplateExtension type to widen to string instead of the intended literal union
type (ftl | ftlh | ftlx), which necessitates an unsafe type cast workaround in
CreateFileDialogContainer.tsx. Add `as const` to the end of the
TEMPLATE_EXTENSIONS array definition to force TypeScript to preserve the literal
types, which will automatically narrow TemplateExtension to the correct union
type and eliminate the need for the type cast workaround.

In `@ui/app/src/utils/path.ts`:
- Around line 364-367: The regex pattern in the first replace call within
getFileNameWithExtensionForItemType only handles de-duplication of .groovy and
.ftl extensions, but with the new .ftlh and .ftlx extensions added in this PR,
duplicated instances of these new extensions (e.g., name.ftlh.ftlh or
name.ftlx.ftlx) will not be caught. Update the regex pattern to include
alternation groups for both .ftlh and .ftlx extensions alongside the existing
.groovy and .ftl patterns, ensuring all four extension types are properly
de-duplicated when they appear consecutively.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fbe12d09-64a5-4b55-a04f-248f71bbf73b

📥 Commits

Reviewing files that changed from the base of the PR and between c6402fd and b381d7f.

📒 Files selected for processing (3)
  • ui/app/src/components/CreateFileDialog/CreateFileDialogContainer.tsx
  • ui/app/src/components/CreateFileDialog/utils.ts
  • ui/app/src/utils/path.ts

Comment thread ui/app/src/components/CreateFileDialog/utils.ts Outdated
Comment thread ui/app/src/utils/path.ts Outdated
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.

1 participant