Reputation: 369
I want to utilise highlight.js
in a a-h/templ
template, but I can't get the pre block to format correctly.
The goal is to have:
<pre>
<code class="language-go">
var User struct {
ID int
}
</code>
</pre>
in the templ file, but I'm having the following problems:
{
. If I switch the {
to (
, it renders.var User struct ( ID int )
on a single lineI've tried @templ.Raw
, but that doesn't resolve either issue (doesn't escape the {
, and can't handle line breaks)
Is there a way to render pre-formatted content like this, do do I need to look for a different solution?
Upvotes: 1
Views: 165
Reputation: 369
After going through the docs page by page, and answer was in Expressions > Escaping
This works nicely:
<pre>
<code class="language-go">
{ `type User struct {
ID int
}` }
</code>
</pre>
Upvotes: 0