Closed MichaelDrogalis closed 11 years ago
I'm not completely sure about this patch.
The main problem is that CSS or JS files are usually included as resources, and resources are not necessarily contained within an directory on the filesystem.
So this code would work if you were deploying directly to a filesystem, but wouldn't work if you packaged your application up in a war or jar file.
For the small number of lines of code it saves, I'm not certain it's worth using a strategy that depends so heavily on how the application is deployed, at least not in Hiccup core.
I see your point. I think it saves a lot more than a few lines of code though. Bigger projects accrue dozens of CSS and JS files. Manually adding them incidentally complex.
Can you give an example of where resources can be contained other than the file system? You mean like, a separate static file server?
I mean resources in the Java sense, which are located on the classpath. This can be as files, but might also be packaged in jars. For instance, the hiccup-bootstrap library contains the Boostrap JS and CSS files as resources.
Being able to add a whole directory of CSS or JS files is convenient, and makes things easier, but it doesn't make the problem less complex. On the contrary, it means your application can be affected by both your source code, and the content of a directory on the filesystem, which is complecting the problem.
Not that this is necessarily bad; sometimes it's better to have a slightly more complex solution if it makes things easier.
My thought is that this code shouldn't be in Hiccup core, but I'd encourage you to put it in another library so it can be easily used by anyone who wants it.
I think that's a fair solution. Any suggestions for the name?
I'm afraid you're on your own there, but I wouldn't object to you using "hiccup" in the name. (Perhaps hiccup-include-all?)
Lopped it into hiccup-pipeline, for the record.
One of the most frustrating things to lose when you switch from Rails to Compojure or Noir is the nicety that all of your JS and CSS files are automatically included. Right now this needs to be done manually for each file with
(include-css ...)
or related.I've written two functions that, given a root directory, will generate CSS or JS includes for each relevant file recursively.