question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Templating] Complex expressions are not handled properly

See original GitHub issue

Platform

  • JavaScript
  • .NET

Version of SDK

All versions since release

Details

The templating engine fails to correctly interpret complex expressions such as this one:

"targetElements": "${foreach(foreach(indicesAndValues(LineItems), x, concat('cardContent', x.index)), y, json(concat('{ \"elementId\": \"', y, '\", \"isVisible\": true }')))}"

The reason for this is the code mistakenly interprets the } character after \"isVisible\": true as being the end marker for the expression when it is actually a character within a string within the expression.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
Steveniccommented, Nov 10, 2020

@dclaux FYI… You can simplify your expression:

"targetElements": "${foreach(foreach(indicesAndValues(LineItems), x, concat('cardContent', x.index)), y, {elementId: y, isVisible: true})))}"

That’s the same thing as using json() to parse a JSON based string but way easier to write 😃

0reactions
golddovecommented, Mar 3, 2021

@RebeccaAnne @jwoo-msft either Status-Fixed label should be removed, or the .NET part should be split into a new issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

refuse to parse complex JS template literals · Issue #60055
The parser would then (mostly) properly handle javascript comments, regexp, strings, etc. If we attempted to transition to another state, ...
Read more >
In Mustache templating is there an elegant way of ...
I think a better way is to change the model dynamically. For example, if you are using JavaScript: model['items'][ model['items'].length - 1 ] ......
Read more >
How to handle trailing commas in template loops - Terraform
I tried numerous workarounds but was not able to find a way to generate valid JSON with complex objects in loops.
Read more >
Expressions | Handlebars
Handlebars expressions are the basic unit of a Handlebars template. You can use them alone in a {{mustache}} , pass them to a...
Read more >
Expressions - Lit
Template structure; Non-literal statics. Lit templates can include dynamic values called expressions. An expression can be any JavaScript expression.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found