sculpin/sculpin.io

Escape twig variables in code blocks

emmajane opened this issue · 2 comments

When I was editing the "Get Started" page I noticed that the twig variable in the sample blog post is actually being rendered. I'm not sure this is the desired effect?

Source:

**So is twig, because it knows this page's name is: {{ page.title }}**

Rendered page:

**So is twig, because it knows this page's name is: Get Started**

Sample URL: https://sculpin.io/getstarted/

You want to wrap code that Twig would otherwise render in {% verbatim %}{% endverbatim %} blocks. So in this particular case, the following would work:

**So is twig, because it knows this page's name is: {% verbatim %}{{ page.title }}{% endverbatim %}**

Or ...

{% verbatim %}**So is twig, because it knows this page's name is: {{ page.title }}**{% endverbatim %}

I'm not sure how badly the latter will mangle the Markdown. I usually end up doing verbatim blocks with larger chunks of code.

```
{% verbatim %}<div>
    This is a sample template: {{ page.title }}
</div>{% endverbatim %}
```

Of course I didn't try rendering any of these examples so I might have some typos, but this is usually the route I take. We just recently fixed a bug that made verbatim work better (see sculpin/sculpin@e6f08db and sculpin/sculpin#122).

Can you try one of these and see if it fixes your issue?

Aha!! That works. Thanks. :) No additional fix required. Closing the issue.