1

I'm trying to display a html template as markup in a code block

<div>
    <pre class="prettyprint lang-html">
        <code>
            <%= template %>
        </code>
    </pre>
</div>

But the template actually renders in the browser, rather than the markup displaying in a code block.

I've included the CDN script in my body tag

<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
colmtuite
  • 4,311
  • 11
  • 45
  • 67

1 Answers1

2

You still need to escape html entities to prevent them from being displayed on the page. &, <, and > need to be changed to &amp;, &lt;, and &gt;.

Blue
  • 22,608
  • 7
  • 62
  • 92
  • How to do that? Why the plugin does not do it by defaut? – Steffi Oct 12 '16 at 10:24
  • Because @Steffi, what if you wanted to bold a section of your code? You wouldn't be able to do that, because google code would have automatically escaped all those bold tags. Escaping your code would either need to be done by hand, or specific to a programming language (If it's stored in a variable) – Blue Oct 12 '16 at 19:18