diff --git a/app/assets/javascripts/discourse/app/components/render-glimmer-container.gjs b/app/assets/javascripts/discourse/app/components/render-glimmer-container.gjs
index 84efab4a79a..4ba5be51b4b 100644
--- a/app/assets/javascripts/discourse/app/components/render-glimmer-container.gjs
+++ b/app/assets/javascripts/discourse/app/components/render-glimmer-container.gjs
@@ -7,10 +7,12 @@ export default class RenderGlimmerContainer extends Component {
{{#each this.renderGlimmer._registrations as |info|}}
{{#in-element info.element insertBefore=null}}
+ {{~! no whitespace ~}}
+ {{~! no whitespace ~}}
{{/in-element}}
{{/each}}
diff --git a/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs b/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs
index 3d1b8a2f675..d0642bcd739 100644
--- a/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs
+++ b/app/assets/javascripts/discourse/tests/integration/helpers/raw-test.gjs
@@ -89,4 +89,19 @@ module("Integration | Helper | raw", function (hooks) {
assert.true(willDestroyCalled, "component was cleaned up correctly");
});
+
+ test("does not add extra whitespace", async function (assert) {
+ const SimpleTemplate = baz;
+
+ addRawTemplate("raw-test", () =>
+ rawRenderGlimmer(this, "span.bar", SimpleTemplate)
+ );
+
+ await render(
+
+ {{raw "raw-test"}}
+ );
+
+ assert.dom("span.bar").hasText(/^baz$/);
+ });
});