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

Fails on boolean attributes #1

Closed
ForbesLindesay opened this issue Mar 26, 2016 · 9 comments
Closed

Fails on boolean attributes #1

ForbesLindesay opened this issue Mar 26, 2016 · 9 comments

Comments

@ForbesLindesay
Copy link
Member

e.g.

input(required)
@briancyzhang
Copy link

could you try the following?

input(require='')

@ForbesLindesay
Copy link
Member Author

You can just do input(required=true) but we should support the shorthand. We could alternatively make input(value) be a shorthand for input(value=value) though, and I'm not sure what the best option is.

@leviwheatcroft
Copy link

Additionally.. the error thrown for this is Error: Unescaped attributes are not supported in react-pug which didn't make any sense to me...

@ezhlobo
Copy link
Member

ezhlobo commented Dec 25, 2017

@leviwheatcroft it's an interesting message. Could you provide your code example, so we can help you to handle it?

@leviwheatcroft
Copy link

Now I think about it, I was passing in react props rather than html attributes. I'm using react-bootstrap

I didn't commit the code when it was producing that error but it was something like this:

return pug`
              Table(striped bordered condensed hover)
                thead
                  tr
                    th Created
                    th State
                tbody
                  each batch in batches
                    tr(key = batch.id)
                      td= batch.createdAtDisplay
                      td= batch.state

So Table is a react component from react-bootstrap

@ezhlobo
Copy link
Member

ezhlobo commented Jan 15, 2018

@leviwheatcroft sorry for a long answer, I just missed it. The thing that now this plugin does not care about shorthands...

In your case you can do a workaround:

Table(striped=true bordered=true condensed=true hover=true)

BTW only one short attribute works fine:

Table(striped bordered=true condensed=true hover=true)

@leviwheatcroft
Copy link

Yeah that's the workaround I'm using, it's not a big deal and I can live without the shorthand syntax. the main thing I was bringing to your attention is that the error thrown doesn't really help you identify the problem. The error is: Error: Unescaped attributes are not supported in react-pug

@ezhlobo
Copy link
Member

ezhlobo commented Feb 11, 2018

Would like to take a look at this issue closer after finishing with issue in pug-lexer (pugjs/pug#2956).

I'm going to allow passing attributes as is (without shorthands). JSX will understand such attributes like boolean attributes with true value.

//CC @ForbesLindesay

@ezhlobo
Copy link
Member

ezhlobo commented Mar 20, 2018

@ForbesLindesay I believe we can close this issue, since it's fixed in v4.2.

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

4 participants