Closed mansona closed 9 months ago
What would also be needed is this: https://github.com/patricklx/ember-template-tag/blob/48981bbdd682144403216f4b44e64d99d5504fd8/__tests__/preprocess-embedded-templates.test.ts#L44
This is so that offsets do not change anywhere
This is required to unblock Glint: https://github.com/typed-ember/glint/pull/615
turns out half the tooling out there needs line/col information.
I would add that: it would be fine to do an exact port of the existing parse API that just emits location information. But I'm pretty sure every place that uses that API also immediately follows up by slicing and dicing the source to replace the content tags.
So it would be even better to
preprocess
accept an optional replacement callback that controls what we transpile the content tags intoThis would eliminate the need for other systems like glint or the eslint plugin to do their own source mangling after calling content-tag.
I think ember template lint uses only location info. Also, i do not think we need some callback transform. It willl just complicate things. Since one needs to distinguish between class body and others. We just need another format which can be parsed and does not change any location information around the templates.
I think ember template lint uses only location info.
No, ember-template-lint does exactly the kind of slicing I'm talking about in _applyFixes.
It willl just complicate things. Since one needs to distinguish between class body and others.
But this is the whole point of why we made content-tag. It already knows that difference! The proper place to detect that difference is in the parser. A lot of the way the existing system worked is hacks to get around the fact that the previous parser can't tell the difference, and we can get rid of those hacks now.
Oh, i understand it wrong then. You mean slice original source to extract template content? That's what the meta data of ember-templatr-tag also emits.
2. What do you mean by the replacement callback then? Maybe can you give an example, then i might understand it better.
Look at this file and port over the tests.
ember-template-tag
(a js implementation)parseTemplates
parseTemplates
does not exist incontent-tag
todaycontent-tag
content-tag
that makes the above implemented tests pass