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

Mixin attributes does not override existing attributes #86

Closed
char101 opened this issue Nov 3, 2021 · 2 comments · Fixed by #87
Closed

Mixin attributes does not override existing attributes #86

char101 opened this issue Nov 3, 2021 · 2 comments · Fixed by #87

Comments

@char101
Copy link

char101 commented Nov 3, 2021

Hello,

I encountered an issue with the following code:

mixin btn()
  a(href='#')&attributes($attributes)

+btn()(href='/')

I expected to get:

<a href="/"></a>

But I actually get:

<a href="#"></a>

I have tested it with pugjs, and with pugjs, the values in attributes do override existing attributes.

Thanks!

@kylekatarnls
Copy link
Member

Hello, you can work around this issue using the explicit way:

PHP style:

mixin btn()
  a(href=$attributes['href'] ?: '#')&attributes($attributes)

+btn()(href='/')

JS style:

mixin btn()
  a(href=attributes.href || '#')&attributes(attributes)

+btn()(href='/')

I will inspect this. Thanks.

@kylekatarnls
Copy link
Member

You can now update to the latest version (phug/phug 1.9.0) to get the proper precendence.

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

Successfully merging a pull request may close this issue.

2 participants