简体   繁体   中英

Meteor: inject html into client-side file on startup

Using the SSR and inject initial packages, I currently have the following server-side code:

Meteor.startup(function() {

  .....

  Inject.rawHead('importList', function(imports) {
    return imports = Blaze.toHTML(Template.imports);
  });
});

This injects a list of html imports into the head, and works perfectly.

I'd like to modify the function so that the code is injected into /client/imports.html instead of into the head... can this be done?

Looks close to this solution . Try this in the client folder of Meteor or use if(Meteor.isClient) for compactness:

Inject.rawHead('importList', function(imports){
    return imports = Blaze.toHTML(Template.imports)
})

Meteor.startup(function(){
    //...
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM