posthtml / posthtml-modules

Modules Plugin
MIT License
84 stars 11 forks source link

Is there any way to ignore a locals expression? #55

Closed herrherrmann closed 3 years ago

herrherrmann commented 3 years ago

I’d like to use locals inside my modules but keep some of the placeholder syntax around (for another post-processing step outside of posthtml).

Example:

Input:

<!-- my-partial.html -->
<div>{{title}}</div>

<!-- index.html -->
<module href="my-partial.html" locals='{"title": "Here’s my title"}'></module>
@{{ username }} <!-- ...or {{{username}}} or \{{username}} -->

Expected output:

<div>Here’s my title</div>
{{ username }}

Actual output:

<div>Here’s my title</div>
undefined

posthtml-expressions supports the @{{}} syntax to achieve this but posthtml-modules doesn’t seem to interpret them accordingly. Are there any considerations to add this feature or possible workarounds with the current version?

Thanks in advance for any help!

Scrum commented 3 years ago

Hi, ignoring-expressions or ignored-tag

herrherrmann commented 3 years ago

Thanks for the headsup! Interestingly, the only thing that worked for me now was a combination of the two syntaxes:

❌ Ignored expression does not work

@{{ username }}

Output:

undefined

❌ Ignored tag does not work

<raw>{{ username }}</raw>

Output:

undefined

✅ Both together are working

<raw>@{{ username }}</raw>

Output:

{{ username }}