Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue html comment handling

I'm using Vue to produce some html template, I need to include the html conditional comments as per code below.

var productTemplate = new Vue({
    el: '#myApp'
});
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script>

<div id="myApp">
    <div class="some-content">
        This is some content
    </div>

    <!--[if mso]>
      <div>
          this div will only be shown if the condition in the comment is true, in this case the condition is:
          if ( mso (microsoft office) == the html rendering engine) {
            show the html code between the [if mso] and the [endif]
          }
      </div>
    <![endif]-->

    <div class="some-other-content">
        This is some content
    </div>
</div>

But when I open my html page in the browser the html code between the conditional comment is completely removed even though I actually need it to be there.

How can I make Vue include these comments in the template's view?

like image 746
Adriano Avatar asked Nov 22 '17 04:11

Adriano


1 Answers

In Vue 2.4.0+, you can set the comments option to true inside the component if you want to preserve comments in the component's template.

var productTemplate = new Vue({
    comments: true,  // <-- Add this
    el: '#myApp'
});
like image 177
Decade Moon Avatar answered Sep 26 '22 15:09

Decade Moon