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

Unable to render negative numbers #98

Closed
ahallora opened this issue Oct 13, 2021 · 4 comments
Closed

Unable to render negative numbers #98

ahallora opened this issue Oct 13, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@ahallora
Copy link

ahallora commented Oct 13, 2021

Describe the bug
When trying to render out a negative number Stencil breaks and returns nothing. It works with positive numbers and 0.

To Reproduce
Take this input { "test": -1 } and this stencil template {%= test %} and watch it break.

Expected behavior
I would expect stencil to output the negative number in the template.

Environment where template is rendered:

  • Stencil version: 0.3.26
  • Operating System version: Linux / GCP
@achempion
Copy link
Contributor

I checked the error logs,

for the payload

{
  "test": -3
}

the error trace is

Exception in thread "main" java.lang.IllegalStateException: Unexpected character: '-'
	at io.github.erdos.stencil.standalone.JsonParser.simpleParse(JsonParser.java:64)
	at io.github.erdos.stencil.standalone.JsonParser.readMap(JsonParser.java:160)
	at io.github.erdos.stencil.standalone.JsonParser.simpleParse(JsonParser.java:47)
	at io.github.erdos.stencil.standalone.JsonParser.read(JsonParser.java:24)
	at io.github.erdos.stencil.standalone.JsonParser.parse(JsonParser.java:20)
	at io.github.erdos.stencil.standalone.Parser$DataFileFormat$1.parse(Parser.java:37)
	at io.github.erdos.stencil.standalone.StandaloneApplication.processJobs(StandaloneApplication.java:89)
	at io.github.erdos.stencil.standalone.StandaloneApplication.run(StandaloneApplication.java:70)
	at io.github.erdos.stencil.Main.main(Main.java:20)

@erdos erdos added the bug Something isn't working label Oct 13, 2021
@erdos
Copy link
Owner

erdos commented Oct 13, 2021

🤦

@erdos
Copy link
Owner

erdos commented Oct 13, 2021

Hello, thank you for opening the issue. The reason behind the bug is that the standalone stencil runner uses its own JSON parser implementation. (The bug is not present when stencil is used as the service or as a library.) Apparently, it is far from perfect.

I have released version v0.3.27 with the fix for the issue.

@achempion
Copy link
Contributor

Awesome, thank you 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants