Skip to content

.inject() in template with {{each}} is ignored #24

Open
@cyppher

Description

@cyppher

Issue

When calling transformWith with a template that loops over items (with {{#each items}}) the injected function is ignored and outputted as String.

The issue occurs with this (partial) code:
data:

{ "items": [
{ ..., "status": "confirmed" },
...
] }

template:
"{{#each items}}": { "status": "{{_.upperCase(this.status)}}", }

ST code

...
const _ = require('lodash');

return ST.select(embeddedArray)
    .inject({_:_})
    .transformWith(template)
    .root();
...

result
"status": "_.upperCase(this.status)"

Expected result

"status": "CONFIRMED"

When I look into test code, I only see a simple test case, this generic case is not covered.
Can you please take a look into this issue / point me in the right direction for a fix / pull request?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions