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 "none" as an option for attributeSeparator #102

Closed
ziazon opened this issue Jul 28, 2020 · 7 comments · Fixed by #116
Closed

Allow "none" as an option for attributeSeparator #102

ziazon opened this issue Jul 28, 2020 · 7 comments · Fixed by #116
Assignees
Labels
type: feature request Functionality that introduces a new feature

Comments

@ziazon
Copy link

ziazon commented Jul 28, 2020

Request / Idea

pug does not require commas following the attribute definitions, so can we add one more setting option to attributeSeparator so it can be always || as-needed || none ?

Input

container(
  someAttribute="value",
  another="OtherValue"
)

Expected Output

container(
  someAttribute="value"
  another="OtherValue"
)

Additional Context

@Shinigami92
Copy link
Member

'none' is the equivalent of 'as-needed'!
Something like 'none' can potentially BREAK your syntax ⚠️

e.g.:

div(
  class="test"
  :style="'color: red'"         // <- this line has a `:` and can break your code/syntax
)

@Shinigami92 Shinigami92 added the working as intended The issue is working as intended label Jul 28, 2020
@ziazon
Copy link
Author

ziazon commented Jul 28, 2020

'none' is the equivalent of 'as-needed'!
Something like 'none' can potentially BREAK your syntax ⚠️

e.g.:

div(
  class="test"
  :style="'color: red'"         // <- this line has a `:` and can break your code/syntax
)

that just looks like something that shouldn't be done lol but I kind of surprised that breaks your code... what frameworks does that break? it doesn't in vue template="pug"

@Shinigami92
Copy link
Member

Sorry for my rush comment yesterday :)

You can read some parts here #13

I tried following in pughtml (cause I use vue myself)

div(
  class="test"
  :bind="'bind'"
  :bind2="'bind2'"
  @click="click()"
  @click2="click2()"
)

Maybe the update pug-lexer from v4 to v5 made it more safe 🤔

Or maybe it always was only an angular problem 🤷‍♂️

I remember that pug-lint also complains about such problems
Need to rewatch this at work with my huge code base so I can test it in real world

Aside that, feel free to start with a PR
Should be simple, cause it's only a third option

export type AttributeSeparator = 'always' | 'as-needed';

If you need any help, feel free to ask and I can also start writing a CONTRIBUTING.md

@Shinigami92 Shinigami92 removed the working as intended The issue is working as intended label Jul 29, 2020
@Shinigami92
Copy link
Member

At least for the Vue syntax, something has apparently changed at some point 🤷‍♂️

@ziazon
Copy link
Author

ziazon commented Aug 13, 2020

sounds good! sorry for the late response, it's been a busy couple weeks :) I'll see about posting a PR sometime next week. Thanks!

@Shinigami92 Shinigami92 added the type: feature request Functionality that introduces a new feature label Aug 13, 2020
@lehni
Copy link
Collaborator

lehni commented Sep 27, 2020

We've been using attributes with : as the v-bind short-hand in Vue Single File Components without any attribute separators in a large project for over two years, and not once was there a problem with that syntax. I'd be great to have the none option!

lehni added a commit to lehni/plugin-pug that referenced this issue Sep 27, 2020
lehni added a commit to lehni/plugin-pug that referenced this issue Sep 27, 2020
lehni added a commit to lehni/plugin-pug that referenced this issue Sep 27, 2020
lehni added a commit to lehni/plugin-pug that referenced this issue Sep 27, 2020
Shinigami92 pushed a commit that referenced this issue Sep 29, 2020
* Allow "none" as an option for attributeSeparator

Closes #102

* Add unit tests and note for angular syntax

* Remove unused import

* Fix linting errors
@lehni
Copy link
Collaborator

lehni commented Sep 29, 2020

Thank you @Shinigami92 for the help with my PRs and the swift merge and release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Functionality that introduces a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants