Reputation: 469
Is there anyway we can add data like in php echo "something"
in the first html page. I want to know the server's timestamp to format a document created time like 2 hours ago, the document already has a property createdTime
. When I use Meteor.Collection.find
, I cannot add the server time by using transform
.
I can use Meteor.method
but I may have to format time before the result arrives.
Thank you.
Upvotes: 1
Views: 463
Reputation: 4654
the __meteor_runtime_config__
approach is run-once; that is, only changes made at package load time (not Meteor.startup()
) are taken into account, and then the __meteor_runtime_config__
snippet is frozen.
To pass run-time (per-page) metadata to the page, it looks like the only option is to set a custom tag on the <html>
element using the (public, but undocumented) WebApp.addHtmlAttributeHook
API.
Upvotes: 0
Reputation: 469
Well, after digging around the code, here is the answer.
You can use the global variable __meteor_runtime_config__
to add more information to the first downloaded html file. In my case, in a server side javascript file, I add __meteor_runtime_config__.now = new Date().getTime()
and this value will be available on the client side
Upvotes: 1