Skip to content

Conversation

@wout
Copy link
Contributor

@wout wout commented Nov 15, 2025

Purpose

Makes it possible to add arbitrary attributes to inline SVGs.

Description

More than often I need to add attributes to inline SVGs, especially with ARIA, and sometimes class names or data attributes. Until now I've been adding them manually to the SVG source files, but it's easy to lose oversight and forget adding some attributes (like aria-hidden for example).

This PR makes it possible to add arbitrary attributes to the SVG tag:

inline_svg("some/icon.svg", aria_hidden: true, class: "icon")

It also still works with the strip styling flag:

inline_svg("some/icon.svg", false, data_very: "lucky")
# or
inline_svg("some/icon.svg", strip_styling: false, data_very: "lucky")

Finally something I wanted to add for a long time already, allowing to pass the file path without the extension:

inline_svg("some/icon")
# resolves to "some/icon.svg"

Checklist

  • - An issue already exists detailing the issue/or feature request that this PR fixes
  • - All specs are formatted with crystal tool format spec src
  • - Inline documentation has been added and/or updated
  • - Lucky builds on docker with ./script/setup
  • - All builds and specs pass on docker with ./script/test

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jwoertink jwoertink merged commit 5922ff8 into luckyframework:main Nov 17, 2025
7 checks passed
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.

2 participants