0

I am trying to insert comments in my component mark up but it is failing to save with the error : "Failed to save undefined: markup://c:TestComp:6,72: ParseError at [row,col]:[7,72] Message: The string "--" is not permitted within comments.: Source"

This is because of the two dashes that I am using in slds class(like slds-text-heading--medium) for one of the tag that I am enclosing in comments. Is there any work around for this?

For Example :

<!--<div>
        <ui:button class="slds-button--brand" label="click me" aura:id="button" press="{!c.clicked}"/>
        <ui:button class="slds-button--brand" label="click2 me" aura:id="button2" press="{!c.clicked2}"/>
        <button class="slds-button slds-button--brand" press = "{!c.clicked2}">Button</button>

</div>-->

Issue is coming because for buttons I am using slds-button--brand styling and -- is not allowed within commented code.

marked as duplicate by Eric, Brian Mansfield, Santanu Boral, martin, Himanshu Apr 25 '17 at 6:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • <!-- works fine in Lightning components and // works fine in the controllers. Maybe show us the code that is causing you issues? – Eric Apr 24 '17 at 18:11
  • For example : <!--<div> <ui:button class="slds-button--brand" label="click me" aura:id="button" press="{!c.clicked}"/> <ui:button class="slds-button--brand" label="click2 me" aura:id="button2" press="{!c.clicked2}"/> <button class="slds-button slds-button--brand" press = "{!c.clicked2}">Button</button> </div>--> – Nihar Apr 24 '17 at 18:13
  • I've hit the same problem with styles such as slds-text-body--small in the Developer Console when commenting out blocks of markup. Unfortunate design decision on the style naming convention in SLDS. But you can insert simple comments. – Keith C Apr 24 '17 at 18:14
  • The newest SLDS uses underscores because of how double dashes are problematic in many areas like this. The double dashes are going to be supported for 18 months but starting with SLDS 2.3.1 they will be underscores: lightningdesignsystem.com/release-notes – James Sullivan May 29 '17 at 9:11
1

Using an IDE is helpful here as many handle the commenting automatically.

Basically you have to change the -- in the class name to &#45;&#45;

<!--<div class="slds-size&#45;&#45;1-of-1">-->

In the IDE (intelliJ Idea and IC) I simply highlight the lines I want to comment out and hit CMD-/

  • Looks like this might be the way to go until salesforce comes up with some official modifications to styling or the commenting for markup – Nihar Apr 24 '17 at 18:23
1

The reason why it's not allowed is because it will confuse Aura and cause Internal Server Errors. It has to do with how aura uses aura:if to unrender elements. Short of leaving aura for something else, it's not likely to change any time soon. At this point, I would recommend deleting the code out when you're not using it at all (say, because you're experimenting). Most IDEs have virtually unlimited undo/redo navigation, or you could use branches in a source control repository to test out features. You should not be relying on comments to hide code. Comments are for describing what code does.

Not the answer you're looking for? Browse other questions tagged or ask your own question.