Giter VIP home page Giter VIP logo

Comments (2)

winstromming avatar winstromming commented on July 28, 2024

I would veer towards modifying the Handlebar file where appropriate rather than adding additional options, if possible - that's what it's there for. Simplest solution in this instance would be to move the entire {{ > assets }} down, like so:

context.write('    <'+'body>');
context.write(result.innerHTML);
context.write('        {{> assets}}');
context.write('    <'+'/'+'body>');

But then, yes, splitting assets into header and footer can also work. You would need a way to decide how and where they are included, however. Can it be on a component-by-component basis? Should it?

from sassdown.

idflood avatar idflood commented on July 28, 2024

Hmm, but having style tags in body isn't allowed I think. There is a scoped attribute in html5 which would allow this but it looks like browser support is not good yet. But if this was supported it would be a good option.

Maybe splitting the assets automatically based on the tag is the best option then. This way the handlebar template can stay the same and if needed the {{> assets}} can be replaced by a {{> styles}} and a {{> scripts}} can be added at the end of body. This solution should be good enough for almost all cases I think.

To give you an idea here is what I changed locally:

var localStyles = '';
var localScripts = '';
// Generate path to assets for this file
Sassdown.config.assets.forEach( function (asset) {
    var assetString = Sassdown.include(asset, path.dirname(page.dest))
    localAssets += assetString;
    // Also add the asset to either localScript or localStyles for greater flexibility.
    if (assetString.indexOf('<script') !== -1) {
      localScripts += assetString;
    }
    else {
      localStyles += assetString;
    }
});
[...]
Handlebars.registerPartial('styles', localStyles);
Handlebars.registerPartial('scripts', localScripts);

from sassdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.