Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow boolean attributes #1271

Open
aerni opened this issue Nov 27, 2024 · 0 comments
Open

Allow boolean attributes #1271

aerni opened this issue Nov 27, 2024 · 0 comments

Comments

@aerni
Copy link

aerni commented Nov 27, 2024

I think it would be really neat to allow simple boolean attributes to be passed to partials without specifying a value. This is useful for configuration type things.

Current behaviour

Currently, you'll have to pass a value to the parameter to make this work.

Template

{{ partial:block boxed="true" bordered="true" }}

{{ /partial:block }}

Block partial

---
bordered: false
collapsed: false
boxed: false
---

<section class="
    {{ view:bordered == 'true' ?= 'stack-border' }}
    {{ view:collapsed == 'true' ?= 'stack-space-collapse' }}
    {{ view:boxed == 'true' ?= 'py-48' }}
">
    {{ slot }}
</section>

Optimized behaviour

It'd be great if attributes without a value would automatically set the value to true in the context of the partial. Then this should work.

Template

{{ partial:block boxed bordered }}

{{ /partial:block }}

Block partial

---
bordered: false
collapsed: false
boxed: false
---

<section class="
    {{ view:bordered ?= 'stack-border' }}
    {{ view:collapsed ?= 'stack-space-collapse' }}
    {{ view:boxed ?= 'py-48' }}
">
    {{ slot }}
</section>
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

No branches or pull requests

1 participant