Finally, I managed to display the login button! Thanks a lot!
I learned couple of things, very very basic things, so I write them here mostly for newbies like me.
rendered != onRendered
Template.templateName.rendered != Template.templateName.onRendered
(I am curious about the differences, but had no time to research it. Yet.)
Need to wait for internal subscriptions
That’s true.
I had to wait until the services got ready before rendering my Template.splash
using Accounts.loginServicesConfigured();
How to render after data is ready
The following thread and the suggestions cleared my mind a bit:
Good techniques for waiting till data is absolutely finished loading by @brucejo
Now, I understand that dividing templates into several parts and applying a #if helperGuard
makes possible dynamic re-rendering my template. (Is that you, Reactive thingy? )
Template rendering with Blaze
When everything is ideal, Blaze can do the magic, even into a variable. Just call toHTML()
!
Don’t be lazy to read the package sources and API docs!
#BestAdvice
This is how my code looks now:
splash.js
let welcomeMsg = '<p class="loading-message">Welcome</p>';
Template.splash.rendered = function () {
this.splash = window.pleaseWait({
logo: '/img/d2logo.png',
backgroundColor: '#7f8c8d',
loadingHtml: welcomeMsg + Blaze.toHTML(Template.loginButtons)
});
};
Template.splashContainer.helpers({
steamIsReady : () => {
return Accounts.loginServicesConfigured();
}
});
Template.splash.events({
'click #login-button': function() {
Meteor.loginWithSteam();
}
});
splash.html
<template name="splashContainer">
{{#if steamIsReady}}
{{> splash}}
{{/if}}
</template>
Don’t ask me, why I decided to use pcel:loading to create a fancy, centered, animated splash screen for my Steam login button. It is a loading page, not a splash screen, for f’s sake! But it was a nice learning experience… (Even writing this post, I found ways to write my code more cleaner.)
Finally, the button is visible, now the 'click #login-button'
event went missing. But that’s another story…
(Oh, and sorry, I should’ve asked it on StackOverflow.)