Skip to content

fix: allow {basename} in template file-refs with different extensions and resolve Qute {#include} for remote catalogs - #2646

Open
maxandersen wants to merge 2 commits into
jbangdev:mainfrom
maxandersen:1318-basename-in-template-file-refs
Open

fix: allow {basename} in template file-refs with different extensions and resolve Qute {#include} for remote catalogs#2646
maxandersen wants to merge 2 commits into
jbangdev:mainfrom
maxandersen:1318-basename-in-template-file-refs

Conversation

@maxandersen

Copy link
Copy Markdown
Collaborator

Supersedes #1319 (stale since 2022, could not be rebased).

Changes

1. Allow {basename} in template file-refs with different extensions (fixes #1318)

Splits extension validation from placeholder substitution in Init:

  • validateTemplateExtension() checks the primary entry only (first {filename}, or first {basename} if no {filename} exists)
  • resolveBaseName() now only does substitution, no validation

This allows templates like:

{filename}=src.java.qute
prefixed-{basename}.tf=infra.tf.qute

where the .tf file uses {basename} without triggering an extension mismatch error.

Addresses the review feedback from @quintesse on #1319 — validates at least the primary entry, while allowing other {basename} entries to use any extension.

2. Resolve Qute {#include} directives in remote catalog templates

The Qute template engine's locate() callback could not resolve relative {#include} paths (e.g. {#include aws/header.java.qute /}) when the template came from a remote catalog — it only tried ResourceRef.forResource() which doesn't know the catalog's base URL.

Fix: pass the catalog-aware ResourceResolver into TemplateEngine so locate() can resolve relative paths against the catalog base URL during template rendering.

Verified working with jbang init -t=q-aws-lambda-tf@nandorholozsnyak/jbang-cloud wonka.java.

Split extension validation from placeholder substitution in Init:

- validateTemplateExtension() checks the primary entry only (first
  {filename}, or first {basename} if no {filename} exists)
- resolveBaseName() now only does substitution, no validation

This allows templates like:
  {filename}=src.java.qute
  prefixed-{basename}.tf=infra.tf.qute

where the .tf file uses {basename} without triggering an extension
mismatch error.

Fixes jbangdev#1318
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ai-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d654413-6844-4604-9b06-bdf0e1142f95

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

The Qute template engine's locate() callback could not resolve relative
{#include} paths (e.g. {#include aws/header.java.qute /}) when the
template came from a remote catalog. The locate() method only tried
ResourceRef.forResource() which doesn't know the catalog's base URL.

Fix: pass the catalog-aware ResourceResolver into TemplateEngine so
locate() can resolve relative paths against the catalog base URL during
template rendering.
@maxandersen
maxandersen force-pushed the 1318-basename-in-template-file-refs branch from 6f936a4 to 76bf3fb Compare August 23, 2026 22:41
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.

Unable to use {basename} in template file-refs

1 participant