Developer forum

Forum » Feature requests » Template parser

Template parser

Ben Doorn
Reply
Is it possible to generate warnings when the Template parser modifies the templates HTML code. We had an issue with a template with some conditional tags, the template was correct en would always rendered to valid HTML. However, the parsed version of the template contained an extra </div> tag.

Of course by manipulating the source template we could have the parser to output the correct HTML code. Is could help if the parser generated a warning when it assumed invalid HTML and made a modification to it.


Replies

 
Nicolai Høeg Pedersen
Reply
Hi Ben.

Not sure that is possible. But the original needs to be a valid HTML document for the parser not to try fixing the HTML.

I would like a copy of the template so I can check it out.

 
Ben Doorn
Reply
I agree the HTML should be valid but a warning when a modification is made by the parser or even preferably rejecting the template will help detecting errors in a early state.

The code that caused the extra /div was something like:

<!--@If Defined(DwTopGraphicClean)-->
<div class="header_container header_img" style="background-image:url('<!--@DwTopGraphicClean-->');">
<!--@EndIf(DwTopGraphicClean)-->
<!--@If Not Defined(DwTopGraphicClean)-->
<div class="header_container">
<!--@EndIf(DwTopGraphicClean)-->
<!-- Some content -->
</div>

It is clear the parser will generate an extra /div for this. But for this code i didn't expect the extra /div
<div class="header_container<!--@If Defined(DwTopGraphicClean)--> header_img<!--@EndIf(DwTopGraphicClean)-->"<!--@If Defined(DwTopGraphicClean)--> style="background-image:url('<!--@DwTopGraphicClean-->');"<!--@EndIf(DwTopGraphicClean)-->>
is parsed as:
<div class="header_container header_img"></div> style="background-image:url('/Files/Billeder/image.jpg');">

We can filter out the errors with an HTML validator, but a warning for invalid templates is a nice to have.


 
Nicolai Høeg Pedersen
Reply
Well - ok.

That makes the original template invalid since you have 2 opening DIV and only one closing. The if defined statements are left in the parsed templated and not applied until run time.

But will see if we could warn or not accept the template.