Skip to content

Engine: Add auto_close_omitted_tags option#1188

Open
marcoroth wants to merge 1 commit intomainfrom
auto-close-omitted-tags
Open

Engine: Add auto_close_omitted_tags option#1188
marcoroth wants to merge 1 commit intomainfrom
auto-close-omitted-tags

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Feb 16, 2026

This pull request updates the Herb::Engine to have the ability to automatically close omitted HTML closing tags when compiling and rendering templates by introducing a new auto_close_omitted_tags option.

While you are able to omit certain HTML closing tags according to the spec, it can be a bit misleading and confusing to do so. That's why Herb encourages to always close all HTML elements, even if they could be omitted.

This new auto_close_omitted_tags option now allows the templates to remain as they are, but to make sure that the rendered output of the engine is always "fully conforming" to have a closing tag in the rendered output.

For example, this template:

<ul>
  <li>List Item 1
  <li>List Item 2
</ul>

This gets compiled as:

herb compile test.html.erb --no-strict --auto-close-tags

__herb = ::Herb::Engine; _buf = ::String.new; _buf << '<ul>
  <li>List Item 1
  </li><li>List Item 2
</li></ul>
'.freeze;
_buf.to_s

And rendered as:

exe/herb render test.html.erb --no-strict --auto-close-tags

<ul>
  <li>List Item 1
  </li><li>List Item 2
</li></ul>

Builds on top of #1173

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 16, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1188
npx https://pkg.pr.new/@herb-tools/language-server@1188
npx https://pkg.pr.new/@herb-tools/linter@1188

commit: 315b593

@github-actions
Copy link

github-actions bot commented Feb 16, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 315b593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant