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.

PostHTML Expression Delimiter Option Only Applies to Templates, not Layouts

See original GitHub issue
  • Maizzle Version: Framework v3.7.3, CLI v1.4.0
  • Node.js Version: 16.5.0

I’m trying to use Maizzle to output templates for an existing Java/Pebble system, similar to https://github.com/maizzle/framework/issues/346.

I wish to change my PostHTML Expressions delimiters in Pebble from {{ to [[ as documented on the Maizzle website: https://maizzle.com/docs/templates/#options

This is not currently working consistently between layout and template files, however.

This is my layout:

    <div class="border-0 border-solid border-t-2 mt-24 border-brandColor border-b-2">
      <p>Layout square brackets: [[ page.language ]]</p>
      <p>Layout curly braces: {{ page.language }}</p>
      <block name="template"></block>
    </div>

This is my template:

<extends src="src/layouts/main.html">
  <block name="template">
    <p>Template square brackets: [[ page.language ]]</p>
    <p>Template curly braces: {{ page.language }}</p>
  </block>
</extends>

This is my config:

module.exports = {
  build: {
    templates: {
      source: 'src/templates',
      destination: {
        path: 'build_local',
      },
      assets: {
        source: 'src/images',
        destination: 'images',
      },
    },
    posthtml: {
      expressions: {
        delimiters: ['[[', ']]'],
        unescapeDelimiters: ['[[[', ']]]'],
      }
    },
  },
}

And this is the rendered result:

image

Ideally, I would like to be able to use {{ }} freely in Front Matter variables and template HTML with no issues. It’s important to me as well that other templating directives that our existing system uses (e.g. it has loops such as {% for i in x %} {{ i }} {% endfor %} can also be put into Maizzle with minimal friction for our existing developers. 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinpainchaudcommented, Jun 24, 2022

Indeed, that solved my problem. I was not aware of this option. Thank you! 🙏

0reactions
cossssmincommented, Jun 23, 2022

You’ll need to customize it for the components as well:

build: {
    components: {
      expressions: {
        // delimiters etc.
      }
    }
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Use with other template languages (Rails, Phoenix, etc) #346
@bradleybeddoes You're not still having issues with this?! ... PostHTML Expression Delimiter Option Only Applies to Templates, not Layouts # ...
Read more >
Working with Templates - v3.1.x - Kong Docs
Partials are snippets of HTML that layouts can reference. Partials have access to all the same data that its layout does, and can...
Read more >
Template Designer Documentation - Jinja
A template contains variables and/or expressions, which get replaced with values when a template is rendered; and tags, which control the logic of...
Read more >
Designing and Building Websites Using Rock | Rock Community
Not only that, but documentation like this manual makes it simple to quickly ... The Layout and Site options are best used for...
Read more >
Dr.Explain 4.10 : User Guide
your documentation layout, help topics, and content structure. Embed support for keyword indexes and full text search capabilities without programming or ...
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