prettier-plugin-ember-template-tag
prettier-plugin-ember-template-tag copied to clipboard
[Feature] Template tag expression formatting configuration option(s)
💬 Describe the Feature
Add support to format template tag expressions such that template tag blocks start on an indented newline and sub-elements have block indentation. Add a configuration option to turn on or off and possibly add an option to adjust block indentation.
🔬 Use Case
As a developer, I may want my template tag expressions to be formatted so that the template tag blocks have their own section for better visual clarity.
Current Implementation
To my knowledge template tag expressions only format in two ways:
Single-line
const ApplicationTemplate: TOC<ApplicationSignature> = <template><h1>Hello World!</template>;
Multi-line with opening template tag on same line as left-hand argument
const ApplicationTemplate: TOC<ApplicationSignature> = <template>
<main>
<h1>Hello World!</h1>
<main>
</template>;
Proposed Change
This change would allow a developer to change the formatting to this:
Newline with block indentation of 2 (my ideal default)
const ApplicationTemplate: TOC<ApplicationSignature> =
<template>
<main>
<h1>Hello World!</h1>
<main>
</template>;
Newline with block indentation of 0
const ApplicationTemplate: TOC<ApplicationSignature> =
<template>
<main>
<h1>Hello World!</h1>
<main>
</template>;
When writing this plugin, I tried to keep the handling of <template> in line with the guiding philosophy of "What would a function do?" after many lengthy discussions with @wycats. In keeping with that philosophy, I did a little experiment here to see how Prettier would handle this case for a function, and IMO the current implementation most closely matches what Prettier would do for a function.
I will keep this issue open for a bit and reconsider if this feature request gets lots of support.