posthtml / posthtml-expressions

Use variables, JS-like expressions, and even markup-powered logic in your HTML.
Other
123 stars 20 forks source link

'Delimiters' settings don't work correctly #122

Open sakekasi opened 2 years ago

sakekasi commented 2 years ago

Hi,

I'm using posthtml-expressions as a part of maizzle to generate templates. I used the following settings to change my delimiters:

expressions: {
  delimiters: ['[[', ']]'],
  unescapeDelimiters: ['[[[', ']]]'],
}

Which almost worked, but I kept getting this error:

SyntaxError: SyntaxError: Unexpected identifier
    at placeholders (/Users/sakekasi/Vesica/shift-search/node_modules/posthtml-expressions/lib/placeholders.js:62:19)
    at /Users/sakekasi/Vesica/shift-search/node_modules/posthtml-expressions/lib/index.js:190:14
    at Array.reduce (<anonymous>)
    at walk (/Users/sakekasi/Vesica/shift-search/node_modules/posthtml-expressions/lib/index.js:177:27)

when trying to process this code:

{{ #each items }}
  <li class="mt-0 mb-10 ml-32 mr-0">
    <a href="{{ url }}">{{ symbol }}</a>
  </li>
{{ /each }}

I used the workaround detailed here to get a stopgap fix in for the issue, but I wanted to bring the problem up here, so it could get resolved.

Thanks

PS. I also tried doing this:

<raw>
{{ #each items }}
  <li class="mt-0 mb-10 ml-32 mr-0">
    <a href="{{ url }}">{{ symbol }}</a>
  </li>
{{ /each }}
</raw>

and this

<raw>{{ #each items }}</raw>
  <li class="mt-0 mb-10 ml-32 mr-0">
    <a href="{{ url }}">{{ symbol }}</a>
  </li>
<raw>{{ /each }}</raw>

to no avail.