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.
Developer forum
E-mail notifications
Template parser
Ben Doorn
Posted on 21/06/2011 09:29:11
Replies
Nicolai Høeg Pedersen
Posted on 22/06/2011 12:06:45
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.
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
Posted on 22/06/2011 15:00:26
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.
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
Posted on 22/06/2011 15:06:50
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.
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.