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

dataSource value passed to moment function does not render properly #40

Open
RaphiStein opened this issue Apr 9, 2019 · 2 comments
Open

Comments

@RaphiStein
Copy link

I created an HTML widget and in the HTML section, I put the following code:

<p>Date: #{openingDate}</p>
<p>Date: ${moment(#{openingDate}).format('YYYY-MM-DD')}</p>

Expected Output:

Date: 2015-10-15T00:05:32.000Z
Date: 2015-10-15

Actual Output:

Date: 2015-10-15T00:05:32.000Z
Date: ${moment(#{openingDate}).format('YYYY-MM-DD')}

@baumandm
Copy link
Collaborator

baumandm commented Apr 9, 2019

If there's an error in the inline JavaScript (${...}), Cyclotron just dumps the original value out and logs an error into the console. That's what's happening here. In this case, I'm pretty sure the issue is that ${openingDate} is a string, but it's not quoted. Cyclotron doesn't automatically handle this, it just inlines the values as-is and tries to execute.

This version should fix the issue:

<p>Date: ${moment('#{openingDate}').format('YYYY-MM-DD')}</p>

@RaphiStein
Copy link
Author

Indeed that solved it. Thank you very much!
This should be more clear in the docs

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

2 participants