remy / inliner

Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
MIT License
1.1k stars 165 forks source link

Allow string inputs to resolve relative local paths #91

Closed gaberudy closed 8 years ago

gaberudy commented 8 years ago

Sometimes an inline string is contains relative paths to a local file system location. By setting inliner.filename to a proper local path, allow the regular file based URL resolution to take place.

In our case, we are generating the inline string using some JS, and using inliner on the generated code. It looks a bit lie:

var renderOutput = render(...);
var Inliner = require('inliner');
new Inliner({'source': renderOutput, 'filename': localPath + '/placeholder.html'},
            function (error, html) {
    console.log(html);
    if(error) {
        console.error(error);
    }
});

By setting filename, we get relative css and js includes in our renderOutput to be resolved based on the lies in localPath.

Note this is addressing issue https://github.com/remy/inliner/issues/89 - but for my use case...

remy commented 8 years ago

Thanks so much for the PR.

It's currently failing the tests (and I note that you don't have a test showing what you're seeing).

Could you make a few changes as per https://github.com/remy/inliner/blob/master/CONTRIBUTING.md (I can help if you're not sure where to start - you'll need to rebase and force push).

Can you include a test, or at least an example of what you're seeing here so I can validate?

remy commented 8 years ago

Closing as idle. Happy to reopen if there's any response.