patrickkettner / grunt-compile-handlebars

grunt plugin to compile static html from a handlebars plugin
MIT License
115 stars 29 forks source link

concat entire directory into one output file #26

Closed paulmason closed 10 years ago

paulmason commented 10 years ago

Awesome plugin Patrick thanks for all the hard work!

Was trying this out:

'compile-handlebars': {
  settings: {
    "template": "settings/*.handlebars",
    "templateData": "handlebars/*.json",
    "output":  "theme/config/settings.html",
    "helpers": "handlebars/*.js"
  }
}

and it seems to just output the last handlebars file rather than concatenating them. Any ideas?

patrickkettner commented 10 years ago

Hey @paulmason! Sorry I took so long to reply - I am not sure off hand, but can dig in soon to check it out

paulmason commented 10 years ago

Thanks Patrick, really appreciate it!

patrickkettner commented 10 years ago

Hey @paulmason, need to apologize yet again for taking forever to reply :[

So, this is a bit of a pickle. It isn't that its only outputting the last file, its that its overwritting the file for every single file in your glob. The sticky bit is that normally this is exactly what people want. Every time you run compile-handlebars, you want the old files to be overwritten, not append to.

That being said, I think your usecase is totally valid and I want to support it, I just can't think of a way to do it with the current configuration. Would an "append": true sort of option work for you? That feels super clunky, but I can't think of a better way to support both use cases :[

I am 100% open for suggestions, though

paulmason commented 10 years ago

Hey @patrickkettner thanks for letting me know. I think "append": true will do the trick! The other option could be to check the output variable "output": "theme/config/settings.html" if it's one file use append, if it has a wild card "output": "theme/config/*.html" then don't. Not sure if this would be easy to detect though? Thanks for all your help, really appreciate it :)

paulmason commented 10 years ago

@patrickkettner Just did a bit of testing and the append is working, however the output file isn't cleared each time you compile and therefor it contains duplicate data from previous compiles.