Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{{ }} blocks in posts are parsed as if they are part of a template #477

Open
WyriHaximus opened this issue Mar 5, 2023 · 4 comments
Open

Comments

@WyriHaximus
Copy link
Member

While working on a GitHub Actions related post got a report that only the $ in ${{ matrix.os }} was visible. Hot fixed it using {{ "${{" }} matrix.os }}. But not sure if the post themself should be run through Twig as a template

@beryllium
Copy link
Member

I believe sculpin posts, at least markdown ones, go through two layers of processing: twig, and then markdown to html. IIRC frontmatter is used to set the twig template to include from, and sculpin populates the content block of the template. However, I might have the order of operations reversed.

As an example, in my posts where I summarize conferences, I use a Twig macro to ensure each talk summary has the same appearance.

@WyriHaximus
Copy link
Member Author

Cool, that makes sense, but should that also affect code inside code blocks using ``` blocks?

@beryllium
Copy link
Member

I would prefer that it didn't, but I suspect that at the evaluation point in the code, the parser would have no idea what code blocks mean.

Maybe if the code block were encased in a verbatim tag?

{% verbatim %}
    ```
    {{ my-twig-example }}
    ```
{% endverbatim %}

@simensen
Copy link
Member

simensen commented Mar 6, 2023

I never got to where I was happy with this chicken or the egg problem. I came to the conclusion the best solution would involve writing a proper Twig/Markdown lexer/parser or something along those lines because whether you process one vs the other first hashadmajor impact on everything and it seemed like there was no good/sure way to handle it. :-/

I know for my own posts some combination of verbatim and breaking things out (like your {{ "${{" }} matrix.os }} fix) was used depending on which seemed less dirty at the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants