Issue with Front Matter
See original GitHub issueI’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 }}͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ‌
 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ‌
 ͏ ͏ ͏ ͏ ͏</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('mails.pledge_created.preheader')͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ‌
 ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ‌
 ͏ ͏ ͏ ͏ ͏</div>
<div role="article" aria-roledescription="email" aria-label="@lang('mails.pledge_created.subject')" 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('mails.pledge_created.preheader')
.
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:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That did it. Thanks a lot for your help!
Try double-ignoring in FM, and keep using triple curly braces:
The way expressions work in FM in Maizzle is that they get evalated twice:
So when it gets to
{{{ page.language }}}
, it’s basically{{{ {{ app()->getLocale() }} }}}
, which is why you gotundefined
.Double ignoring would mean it sees
{{{ @{{ app()->getLocale() }} }}}
- the triple braces output the unencoded result of@{{ app()->getLocale() }}
, giving you the correct output.