Skip to content

Support valueless HTML attributes in rendered markup#2

Draft
maxpertici with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-input-html-attribute-output
Draft

Support valueless HTML attributes in rendered markup#2
maxpertici with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-input-html-attribute-output

Conversation

Copilot AI commented May 17, 2026

Copy link
Copy Markdown

Rendering currently requires key="value" for every attribute, which prevents valid HTML boolean/valueless attributes like required. This update allows emitting attributes without values while preserving safe attribute rendering.

  • Attribute rendering behavior

    • Updated wrapper attribute serialization in Markup::wrapperOpenerTag():
      • '' (empty string) now renders as a valueless attribute (required)
      • non-empty values continue rendering as key="value"
  • Output safety

    • Escaped non-empty attribute values at render time with htmlspecialchars(..., ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') before interpolation.
  • Docs

    • Added a setAttribute('required', '') example in docs/markup.md to document boolean/valueless attribute usage.
$input = Markup::make('input', attributes: [
    'required' => '',
    'name' => 'email',
]);

echo $input->render();
// <input required name="email"></input>

Copilot AI linked an issue May 17, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 17, 2026 06:00
Agent-Logs-Url: https://github.com/maxpertici/markup/sessions/33d47551-a128-48fb-ba92-0103db3992c5

Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com>
Agent-Logs-Url: https://github.com/maxpertici/markup/sessions/33d47551-a128-48fb-ba92-0103db3992c5

Co-authored-by: maxpertici <48124450+maxpertici@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue with outputting HTML attribute without value Support valueless HTML attributes in rendered markup May 17, 2026
Copilot AI requested a review from maxpertici May 17, 2026 06:01
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.

Can't output html attribute without value

2 participants