Opened 5 years ago

Last modified 4 years ago

#18891 new enhancement

Allow comments in templates

Reported by: artclifford Owned by:
Priority: undecided Milestone: 1.14
Component: Parser Version: 1.10.5
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

This is likely related to:

A new developer attempted to comment out code in a template during development and dojo gave an invalid template error.

Presumably it thinks that the comment tag is an additional node at the top level of the component template.

I would argue this is a defect in that comments are a throw back to REM statements (Read Erase Memory) and are part of every language worth working with. The comments are being treated as actual container elements at the top level of the component which is not valid.

Comments are allowed within the template so long as they are within the outer most element.

<div><!-- a comment --></div>  // works
<!-- a comment --><div>...</div> // does not work.
<div>...</div><!-- a comment --> // does not work.

I am not in a position to develop on this project at this time, but it seems to me that the function doing the element count check to determine template validity might be a good place to remove an element in a template that is an html comment at the top level of the template.

While a workaround is simple (move comment into outer element), it is contrary to what one is used to in programming in general. You don't document a function using / / blocks inside a function.

I do not know if this has been addressed in more recent versions since the previous ticket was marked patchwelcome, but it should be especially to aid in lowering the barrier to entry, however minory, for people coming in from other language experiences.

Change History (3)

comment:1 Changed 5 years ago by bill

Component: HTMLParser
Description: modified (diff)
Type: defectenhancement

Right, and this works in delite (which we meant as the successor to dijit). See #15399 (in addition to #5456 that you mentioned). No objection if somebody wants to fix it in Dojo V1 too.

comment:2 Changed 5 years ago by dylan

Milestone: tbd1.13

comment:3 Changed 4 years ago by dylan

Milestone: 1.131.14
Note: See TracTickets for help on using tickets.