How to comment out knockout code in HTML
Asked Answered
F

2

5

Is there any to comment out a knock out code in HTML, since the ko code is already in default html comment block.

<!-- ko if : isEditable() -->
    <!-- Edit Mode -->
    <div class="edit">Edit mode</div>
<!-- /ko -->

Can I comment the above section in my html

Fair answered 7/6, 2018 at 6:37 Comment(0)
F
3

Just change the ko to anything else!

<!-- koc if : isEditable() --> or <!-- kcomment if : isEditable() --> anything other that ko makes it as a comment.

As knockout looks only for html comments that start with ko, anything other than ko on an html comment will simply be a comment.

Fair answered 29/6, 2018 at 6:52 Comment(0)
K
7

In our project we tend to use <!-- kocomment if : isEditable() --><!-- /kocomment --> syntax which effectively turns ko statement into a simple html comment (knockout does not care for such comments).

Or you may use shorter additions to ko word. Just make sure to comment out both opening and closing statement, there is also risk that this commented comment will not stand out, unless you have some knockout syntax highlighting.

Kelter answered 7/6, 2018 at 6:45 Comment(0)
F
3

Just change the ko to anything else!

<!-- koc if : isEditable() --> or <!-- kcomment if : isEditable() --> anything other that ko makes it as a comment.

As knockout looks only for html comments that start with ko, anything other than ko on an html comment will simply be a comment.

Fair answered 29/6, 2018 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.