Open knightcode opened 6 years ago
That was an intentional change on the current master here, which is not yet documented properly. Basically the new version will require you to pass the contents of a custom template file instead of the path. Does it work when you read the file contents with fs.readFileSync
?
eh. I don't really like the idea of including the template in Gruntfile.js. It's seems cleaner to have it separated off in its own file with which I can do a git diff
independently of other code. Gruntfile is configuration.
It also seems harder to include a custom template if you ever provide a CLI.
You dont have to have it in your gruntfile, you just need to read it there. And for the CLI some code would be needed anyways so than can include reading custom templates. Of course it is one more line in your gruntfile but it makes the sprite generator much more versatile. The whole code can be executed independent of the javascript runtime that is used, e.g. in the browser. See https://github.com/selaux/node-sprite-generator/pull/67.
I can't really imagine the app that would inflict that work on it's user, but I get what you're going for.
It still seems like you could load the 'fs' dependency only if the config calls for it and not obliterate your legacy users like me. But I don't keep grunt running in production, so my template will only waste memory on my MacBook while 'grunt watch' is running. I guess I can deal with that.
For each template type, lib/stylesheet/index.js calls
getTemplatedStylesheet
once passing in the contents of a file for the respective built in template, andgetTemplatedStylesheet
then returns a function that is used asrenderStylesheet
in nsg.js.However, when using a custom template file,
getTemplatedStylesheet
is passed the filename instead of the contents of the file.