Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to comment out knockout code in HTML

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

like image 407
Jerin Joseph Avatar asked Jan 03 '23 07:01

Jerin Joseph


2 Answers

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.

like image 148
Olga Avatar answered Jan 05 '23 15:01

Olga


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.

like image 43
Jerin Joseph Avatar answered Jan 05 '23 17:01

Jerin Joseph