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

Add third option for pugClassNotation and pugIdNotation #167

Open
Shinigami92 opened this issue Nov 28, 2020 · 5 comments
Open

Add third option for pugClassNotation and pugIdNotation #167

Shinigami92 opened this issue Nov 28, 2020 · 5 comments
Labels
help wanted We are looking for community help type: feature request Functionality that introduces a new feature

Comments

@Shinigami92
Copy link
Member

This will be a follow-up of #36, because this third option will need a bit more refactoring and is not quite as easy to implement as the other two options.
To let users already benefit from the other two options, we will create a release before starting working on this third option.

@Shinigami92 Shinigami92 added the type: feature request Functionality that introduces a new feature label Nov 28, 2020
@Shinigami92 Shinigami92 added the help wanted We are looking for community help label Jan 23, 2021
@homerjam
Copy link
Contributor

homerjam commented Apr 8, 2021

This will be extremely helpful when using Tailwind!

Has this been started? Are there any pointers available for where to begin?

@Shinigami92
Copy link
Member Author

Shinigami92 commented Apr 8, 2021

It's kinda easy to start by adding the new option to the choices:

choices: [
{ value: 'literal', description: 'Forces all valid classes to be printed as literals.' },
{ value: 'as-is', description: 'Disables class formatting.' }
]

choices: [
{ value: 'literal', description: 'Forces all valid ids to be printed as literals.' },
{ value: 'as-is', description: 'Disables id formatting.' }
]

And then add tests for the option in

From there you can then just try-and-error through the code with test-driven-development ^^

Just use yarn test tests/options/pugClassNotation and yarn test tests/options/pugIdNotation

@Shinigami92
Copy link
Member Author

@h0merjam The third choice should be attribute (opposite of literal ^^)

And then your both function friends are here and below: https://github.com/prettier/plugin-pug/blob/main/src/printer.ts#L577

start-attributes and attribute

@homerjam
Copy link
Contributor

Hmm, this isn't quite as simple as I'd hoped!

I've tried to grasp what's happening with the literal option and how the attribute option might work. Based on what I think I understand so far the steps might be:

  • store literals via class/id token type processor (this would require adding new private vars to the PugPrinter class❓ - classesToAppend / idToAppend)
  • convert/append literals to class/id attribute (either in existing class attribute or end-attributes / newline hooks)

Does this sound about right? 🤔

@Shinigami92
Copy link
Member Author

Shinigami92 commented Apr 20, 2021

Yes that sounds right 👍

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

No branches or pull requests

4 participants