posthtml / posthtml-expressions

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

Each loop not working #125

Closed thewebartisan7 closed 1 year ago

thewebartisan7 commented 2 years ago

In read me there is this example:

<each loop="item in [1,2,3]">
  <p>{{ item }}</p>
</each>

But it seem not working.. Only when passing array via locals.

Also adding below not working:

<script locals>
    module.exports = {
        inputs: [2,3,4,5,6]
    }
</script>

<each loop="item in inputs">
  <p>{{ item }}</p>
</each>
cossssmin commented 2 years ago

All loop tests pass and that works fine, can you please share a repository that reproduces the issue?

thewebartisan7 commented 2 years ago

All loop tests pass and that works fine, can you please share a repository that reproduces the issue?

I can't find in your test the example of this way to define locals:

<script locals>
  module.exports = {
    name: 'Scrum'
  }
</script>

<div>My name: {{name}}</div>

Because this is what I am trying.

Should I prepare a repo with this?

I am using posthtml-loader with webpack.

cossssmin commented 2 years ago

It's here:

https://github.com/posthtml/posthtml-expressions/blob/260a048538e78f79d9d62e15961ecd6f4129d399/test/test-locals.js#L34-L40

Should I prepare a repo with this?

Yes please if you can, thanks.