question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with Front Matter

See original GitHub issue

I’m using Maizzle with Laravel. I want to dynamically render the title and preheader.

I’ve got this in the Front Matter of my template:

---
title: "@lang('mails.pledge_created.subject')"
preheader: "@lang('mails.pledge_created.preheader')"
---

In my master template I’ve got this:

<body class="{{ page.bodyClass || '' }}">
  <if condition="page.preheader">
    <div class="hidden">{{ page.preheader }}&#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &zwnj;
      &#160;&#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &zwnj;
      &#160;&#847; &#847; &#847; &#847; &#847;</div>
  </if>
  <div role="article" aria-roledescription="email" aria-label="{{ page.title || '' }}" lang="{{ page.language || 'de' }}">
    <block name="template"></block>
  </div>
</body>

The output looks like this:

<body style="margin: 0; padding: 0; width: 100%; word-break: break-word; -webkit-font-smoothing: antialiased; background-color: #f4f5f7">
    <div style="font-family: 'Segoe UI', sans-serif; mso-line-height-rule: exactly; display: none">@lang(&#039;mails.pledge_created.preheader&#039;)&#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &zwnj;
      &#160;&#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &#847; &zwnj;
      &#160;&#847; &#847; &#847; &#847; &#847;</div>
    <div role="article" aria-roledescription="email" aria-label="@lang(&#039;mails.pledge_created.subject&#039;)" lang="de" style="font-family: 'Segoe UI', sans-serif; mso-line-height-rule: exactly">

Instead of outputting @lang('mails.pledge_created.preheader') it outputs @lang(&#039;mails.pledge_created.preheader&#039;).

This only happens in those two instances though. If I add @lang('mails.pledge_created.preheader') anywhere else in the template or the master it works as expected.

  • Maizzle Version: 3.3.0
  • Node.js Version: 15.11.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aernicommented, Apr 14, 2021

That did it. Thanks a lot for your help!

0reactions
cossssmincommented, Apr 14, 2021

Try double-ignoring in FM, and keep using triple curly braces:

language: "@@{{ app()->getLocale() }}"
<html lang="{{{ page.language }}}">

The way expressions work in FM in Maizzle is that they get evalated twice:

  • once when evaluating all FM content
  • twice when evaluating the entire template

So when it gets to {{{ page.language }}}, it’s basically {{{ {{ app()->getLocale() }} }}}, which is why you got undefined.

Double ignoring would mean it sees {{{ @{{ app()->getLocale() }} }}} - the triple braces output the unencoded result of @{{ app()->getLocale() }}, giving you the correct output.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Front Matter for GitHub Pages · Issue #144
If making markdown files for GitHub Pages, a header in the Front Matter format is needed. It would be nice if this will...
Read more >
Troubleshooting - Front Matter CMS
One of the main issues you may encounter is that there is something wrong in your markdown its front matter. This can be...
Read more >
Having trouble accessing front matter in template - HUGO
This seems like something basic, but I can't figure out why it doesn't work. I have MathJax on my blog, but only 10%...
Read more >
FRONT MATTER | Contemporary Issues in Mediation
FRONT MATTER · Joel Lee · Marcus Lim · William Ury.
Read more >
Format Front Matter, Body Matter, and Back Matter
Front matter includes all content that appears prior to chapter one or the main body text. Front matter elements usually appear in this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found