Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

279
Views
Why vhtml not rendering nested << properly?

I have an app that uses dynamic binding where <> is a dynamic way of getting value from API. But when I am trying to render it in vhtml, its not even showing the parent element. I want it like Name: <<Name>>. How this can be achieved? . I have attached the example code.

const app = new Vue({
  el: '#app',
  data () {
    return {
      htmlText: '<p> Name : <<Name>> </p>'
    }
   }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<span v-html="htmlText"></span>
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

On top of Link's and Xlm's answers on vue: escape and render HTML string?

Parse the incoming string with a regex that replaces < with &lt; and > with &gt;

Please note that this could be just a workaround. If you want a cleaner solution, you should do this in the API.

In your case,

 const app = new Vue({
   el: "#app",
   data() {
      return {
        htmlText: "<p> Name : <<Name>> </p>",
      };
   },
   methods: {
      htmlToText(html) {
          return html.replace(/<</g, "&lt;&lt;").replace(/>>/g, "&gt;&gt;");
      },
   },
});
<div id="app">
  <span v-html="htmlToText(htmlText)"></span>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!