Search code examples
node.jshandlebars.jsconnect-assets

Connect assets with handlebars?


The typical way to include the connect assets file is

!= css("main")

That is with .jade though. I am using handlebars and I have no clue how I can add the file?

I am using node-sass as well.


Solution

  • Just guessing, something like this works (see blog post):

    var connectAssets = require("connect-assets")();
    app.use(connectAssets);
    var hbs = require('hbs');
    hbs.registerHelper('css', function() {
      var css = connectAssets.options.helperContext.css.apply(this, arguments);
      return new hbs.SafeString(css);
    });