jte: Can't have unclosed tags after upgrading to 3.0.1
I have few separate KTE files used as components in other KTE pages. One of them is pair of “cardBegin.kte” and “cardEnd.kte”, which, omitting details, contain something like this:
<div ...>
<div ...>
<div ...>
and
</div>
</div>
</div>
Now I’m getting error like this from JTE plugin:
Execution failed for task ':my-project:generateJte'.
> There was a failure while executing work items
> A failure occurred while executing gg.jte.gradle.GenerateJteWorker
> Failed to compile tag/row/card/cardBegin.kte, error at line 10: Unclosed tag <div>.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 29 (22 by maintainers)
Commits related to this issue
- #250 provide further information on unclosed tags — committed to casid/jte by casid a year ago
- #250 declaration tags must not be closed — committed to casid/jte by casid a year ago
@stella6767 you can do it like this. This way IntelliJ should also not complain about an unclosed form tag.
Well, I’m not sure because it requires writing a lot of code instead of just markup. Also, I’m not sure about performance (but it’s not important in my case)
@casid thank you, but I’m afraid, I’ve already rewritten all 5 of my xmls to https://github.com/redundent/kotlin-xml-builder, sorry 😦
Your solution makes me happy.
@casid well, maybe it should be a separate mode, on par with Plain and Html. And… Why not? It’s basically the same boilerplate we all would prefer not to see 😃
@asm0dey oh wow, I did not expect that jte would be used to generate XML 😃
I’ve adjusted the code, so that declaration tags are not expected to be closed.
Yes, I’m working with IntelliJ plugin.
Out of curiosity, are you working with the jte IntelliJ plugin? I’m quite happy with content block layouts.
Without the plugin, I agree it to be less readable.
I’d still feel quite nervous about this alternative though 😉
We have this now because the behavior was different before. Given the exception message, I don’t think new users will have a problem here.
Libraries should make doing the correct thing easy and make making mistakes hard.
Unclosed tags always mean you’ll have to touch two files and know which one is the second file. This makes mistakes easy.
Hey @IvanPizhenko,
I can understand your frustration with this change. This feature was part of the major version bump from jte 2 to jte 3. I haven’t anticipated that it would have such an effect, and missed to notice it in the release notes, it was just mentioned in the issue: https://github.com/casid/jte/issues/194. I’ll add this to the release notes, with a hint how to migrate. I’ll also add a hint to the compile error, pointing to
gg.jte.Content
.However, we did this change because we believe this will result in much cleaner templates, that will be better to maintain in the long run. Not only will this read better in IntelliJ, also users of such templates won’t be able to forget a closing template anymore.
For instance your example could be written as
card.kte
:If you don’t want to migrate right away, it is perfectly fine to stay on jte 2 until you are ready for the change. And maybe give
gg.jte.Content
a try for new templates. I’m very sure you’re gonna like it as much as we do!