Skip to content

fix(mrml-core): forward layout context through mj-include - #696

Merged
jdrouet merged 1 commit into
mainfrom
fix/include-layout-context
Sep 13, 2026
Merged

jdrouet merged 1 commit into
mainfrom
fix/include-layout-context

Conversation

@jdrouet

@jdrouet jdrouet commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Content pulled in through mj-include renders differently from the same content written inline.

inc.mjml = <mj-column><mj-text>hi</mj-text></mj-column>
           <!-- a comment -->

via mj-include : mj-column-per-50
inlined        : mj-column-per-100

The include renderer forwarded only index and siblings to its children, so the comment was counted as a layout sibling and the column rendered at half width. It also never implemented set_container_width, so the width never reached the children at all — an <mj-image> inside an included fragment came out with no width attribute and no width on its wrapping <td>.

Both now match the inlined form: mj-column-per-100, and width="550" on the image.

raw_siblings is computed the way mj_section computes it for its own children — a count of raw children over the child list — rather than the way mj_raw does it. In mj_raw every child is raw so raw_siblings == siblings, but an included fragment holds a mix, and copying that would have been wrong.

Two regression tests comparing included against inlined output with html_compare::assert_similar, both confirmed failing before the change (expected .mj-column-per-100, got .mj-column-per-50; and the missing image width) and passing after. No golden fixture uses mj-include, so the full suite passing is also a clean check that non-include templates are untouched.

Tests 621 -> 623.

Follow-up, deliberately not in here: a section still treats an entire included fragment as one opaque non-raw child, so it emits a single Outlook conditional <td> around the whole include instead of one per column. Fixing that needs the section's child iteration to flatten includes, which is a bigger change than this one.

Signed-off-by: Jeremie Drouet <jeremie.drouet@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

📈 This is how your metrics evolved 📉


@jdrouet
jdrouet merged commit 6e9a46d into main Sep 13, 2026
18 checks passed
@jdrouet
jdrouet deleted the fix/include-layout-context branch September 13, 2026 12:57
@github-actions github-actions Bot mentioned this pull request Sep 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.

1 participant