Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cyppher opened this issue Jul 20, 2018 · 5 comments
Open

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

cyppher opened this issue Jul 20, 2018 · 5 comments

Comments

@cyppher
Copy link

cyppher commented Jul 20, 2018

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!

@cyppher cyppher changed the title Inject in template with {{each}} is ignored .inject() in template with {{each}} is ignored Jul 20, 2018
@cyppher
Copy link
Author

cyppher commented Aug 17, 2018

bump the lack of injectable code within an each block is really getting in the way for me. Let's have a chat on how to resolve this.

@smtrd3
Copy link

smtrd3 commented Sep 11, 2018

Is this issue fixed yet?

@cyppher
Copy link
Author

cyppher commented Sep 12, 2018

@smtrd3 not that I'm aware of.

@smtrd3
Copy link

smtrd3 commented Sep 12, 2018

I noticed that all the injected objects can be accessed as something like "{{ $root.moment() }}" even from inside #each block. Don't know whether it is correct approach or not.

@umaparvathy
Copy link

Is this issue fixed yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants