Cannot set containing close tag to skip when model level is zero

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cannot set containing close tag to skip when model level is zero

Marc Logemann
Hi,

getting this Exception:

Caused by: org.attoparser.ParseException: Cannot set containing close tag to skip when model level is zero
        at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
        at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
        at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
        ... 66 common frames omitted
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Cannot set containing close tag to skip when model level is zero
        at org.thymeleaf.engine.TemplateModelController.skipCloseTag(TemplateModelController.java:307)
        at org.thymeleaf.engine.TemplateModelController.skip(TemplateModelController.java:293)
        at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1594)
        at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205)
        at org.thymeleaf.engine.Model.process(Model.java:282)
        at org.thymeleaf.engine.Model.process(Model.java:290)
        at org.thymeleaf.engine.GatheringModelProcessable.process(GatheringModelProcessable.java:78)
        at org.thymeleaf.engine.ProcessorTemplateHandler.handleCloseElement(ProcessorTemplateHandler.java:1640)
        at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleCloseElementEnd(TemplateHandlerAdapterMarkupHandler.java:388)
        at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:322)
        at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleCloseElementEnd(OutputExpressionInlinePreProcessorHandler.java:220)
        at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleCloseElementEnd(InlinedOutputExpressionMarkupHandler.java:164)



Since its quite cryptic, i am not sure how to fix it.... tried changing some things in the template without any success. Can anybody point me to something?

Thanks
Marc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

danielfernandez
Administrator
That error means something is modifying the structure/hierarchy of the markup, and apparently doing it wrong because the events increasing/decreasing levels in such hierarchy no longer match.

Which specific version of Thymeleaf 3 are you using? could you confirm if this error is thrown in a th:insert/th:replace or similar?

Also, are you using the Layout Dialect? if so, which version? If it's not the latest, could you try updating?

Are you using any other dialects or custom processors that might perform Model/DOM-modification operations like insertion of fragments, execution of Model Processors, etc?

Ideally (though maybe this is not possible): could you post your template/s, or at least the smallest fragment of them that still throws you the error?

Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

Marc Logemann
turns out that thymeleaf clashes with my handlebars templates like these:

    
     <script id="rights-template" type="text/x-handlebars-template">
        {{#each this}}
        <div class="row">
            <div class="col-md-5"><span class="{{../marker}}">{{right}}</span></div>
            <div class="col-md-5">{{description}}</div>
        </div>
        {{/each}}
    </script>

Any solution to this?

My layout dialect version is 2.0.3.  Thymeleaf 3.0.1 with Spring integration.

Marc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

danielfernandez
Administrator
Hello again Marc,

Does that specific template cause you trouble? I've just added a test for it and it works just fine...

Maybe it's a different template, or a variation of this with a different markup structure?

Regards,
Daniel.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

Marc Logemann
Attached RoleManager.html my complete template. (without the layout file which decorates my template). Dont know if it makes sense w/o having all those external JS libs though.

I am pretty sure its this section because as soon as i remove the handlebars scripts, it works. It works also when i comment the stuff inside the script tag with HTML comment tags


Perhaps you put the script tag in a different section as i ve put it. Dont know. Hopefully you can find something.
 
Thanks
marc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

Marc Logemann
This post was updated on .
it really makes a difference where you put the script block. The problem is inside the head section. If i put them into body section, it works.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

danielfernandez
Administrator
Hello again Marc,

I am completely unable to reproduce your issue :(, your template works perfectly fine for me, except for the fact that I'm not applying layout using the Layout Dialect. I have no issues with your template scripts, no matter where I place them (head or body).

I've tried several combinations of interactions, but none provoke your issue, so right now I'm thinking this could be something caused by the Layout Dialect somehow, which then provokes your exception by means of some kind of interaction with your template's scripts. Maybe it modifies some of your template's events when inserting your file as a fragment?

I know some loosely related issues where found in previous versions of the Layout Dialect, but I believe they should be fixed by the dialect's 2.0.3 version, the one that you are using. Maybe you could try updating to Layout Dialect 2.0.4 (and Thymeleaf 3.0.2), and then if the problem persists report it at the Layout Dialect's GitHub project?: https://github.com/ultraq/thymeleaf-layout-dialect

Regards,
Daniel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

Emanuel
Administrator
In reply to this post by Marc Logemann
Ah, I was hoping that you'd say your layout dialect version was 2.0.1 or older since in 2.0.2 I fixed up a similar issue where you would get this model level problem in some situations.  The <head> situation sounds different though, so I might need to take a look at that.

Any chance you could attach the layout file too?

I've gone and created an issue on GitHub: https://github.com/ultraq/thymeleaf-layout-dialect/issues/138
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cannot set containing close tag to skip when model level is zero

Emanuel
Administrator
In reply to this post by Marc Logemann
Hadn't heard back from you Marc, but if you're still around, I have since released version 2.1.1 of the layout dialect which I hope addresses the last of the model level problems.  2.1.0 included a first pass at this problem (the issue I initially raised because of this forum post, https://github.com/ultraq/thymeleaf-layout-dialect/issues/138), plus a patch and simplification of the model level algorithm which should make it more in line with how Thymeleaf behaves (https://github.com/ultraq/thymeleaf-layout-dialect/issues/142).

Could give 2.1.1 a try and see if that fixes this problem?
Loading...