-
Notifications
You must be signed in to change notification settings - Fork 11
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
when a timestamp is passed as string, it fails #25
Comments
So you're saying that Dust only supports data that's a String being passed to helpers? |
Demo: var tmpl = '<time>{@intlDate val={ts} /}</time>';
var ctx = { ts : (new Date()).getTime() };
dust.renderSource(tmpl, ctx, function(err, out) { console.log(out); });
// Dust error message:
// SyntaxError: Expected buffer, comment, partial, raw, reference,
// section or special but "{" found. |
@ericf You also have a similar issue with one example from your README: Template: To get the correct result, you have to pass |
Does {@intlDate timeZone="UTC" val=mydata.sometimestamp /} work? |
This works for me, but for verbosity you may want to consider the change I proposed in #26 (comment). |
@drewfish that seems to work. thanks!. but it might be good to fix this to accept string too. |
@sfj2 I'm not sure its needed. That just how Dust works, you don't need the quotes or brackets to pass in context values. |
Agree @redonkulus. Maybe then we should fix the readme at least? this is what's there in the readme right now - var timeStamp = (new Date()).getTime(); // 1395872439650 and maybe we should have an example of {@intlDate timeZone="UTC" val=mydata.sometimestamp /} too? i talked to at least 3-4 people who works regularly on dust, and couldn't figure this out :) |
Ya I'd say an example like you mention would be useful. This seems to trip up developers more often than we would like. |
@sfj2 @redonkulus Just look in the PR #26, I've already proposed some fixes for the examples in the README and a note about timestamps. This should do the trick. |
This relates to #35 |
the @intlDate only works if the timestamp is passed as a number, doesn't work if if it's a string, due to this it's almost impossible to use this, since when we have to pass some data to the helper, we can only do it as a string -
eg. -
{@intlDate timeZone="UTC" val=12344555555 /} - works
{@intlDate timeZone="UTC" val="{mydata.sometimestamp}" /} - fails -
{@intlDate timeZone="UTC" val={mydata.sometimestamp} /} - can't do this since dust fails saying it can't match the brackets
The text was updated successfully, but these errors were encountered: