Reputation: 22183
I have a templates directory in my assets folder on my Rails setup which hosts my templated-HTML files. I've implemented a partial system where I can load text snippets into each template so long as it has a .erb file attached to it. The partials are prefixed with an underscore, so /assets/templates/_form.html is a partial which is included inside of /assets/templates/edit.html. This works, but there is an issue when I run assets:precompile.
The assets:precompile command will precompile the _form.html files as well (since they're located inside of the assets/templates folder) and I don't want this to happen since they can't be precompiled (since any erb variables are missing and so on).
Is there any way I can inform the rake assets:precompile command to ignore certain files (in this case files that have an underscore infront of them)? Does someone know how to do this? Or can someone point me to the github repository which has the source for the rake assets:precompile command?
Upvotes: 1
Views: 1232
Reputation: 35360
In Rails 3.2.8 you can find the source for the rake task definition here.
What you're asking has been brought up at least once in Sprockets issues tracker
joshpeek added a new stub
directive in Sprockets 2.2 which looks like a promising solution to 'ignoring' certain assets from the pipeline.
Rails 3.2 doesn't support a version of Sprockets anywhere near 2.2 and there doesn't seem to be any intention on doing so before Rails 4 from what I've read (though I'd love to be wrong about that). Here's at least one closed issue (no action taken) requesting an upgrade to 2.2.
For your situation though, it seems to me that you might be using app/assets
incorrectly. I can't offer an alternative solution as I don't know enough about your setup/usage to say definitively, but as you said, files with .erb
in app/assets
are going to be processed by Sprockets.
Upvotes: 3