I'm starting to implement a precompile and I was wondering if I could
get some feedback about how it's going.
There's a SparkBatchDescriptor which contains multiple entries. You
build it with a fluent interface
var batch = new SparkBatchDescriptor();
batch
.For<HomeController>()
.For<HomeController>().Layout("Ajax").Include("_Notification")
.For<AccountController>();
factory.Precompile(batch);
some unit tests for this:
http://dev.dejardin.org/trac/spark/browser/trunk/src/MvcContrib.SparkViewEngine.Tests/SparkBatchCompilerTester.cs
The default would be to include all views that don't start with a "_",
and to use the layout that's appropriate for the framework. That's why
the first one being implemented is
asp.net mvc... It's simpler... The
castle implementation of precompile will probably need to be aware of
attributes like layout and area.
Calling .For<> starts a new rule entry. Within a rule you can call
Layout, Include, and Exclude multiple times. Include and Exclude can
have patterns that end with *. If the pattern ends with * it won't
find things in "Shared". The other special case is the single
character "*" which matches anything that doesn't start with an
underscore.
So to match all files you'd say .Include("*").Include("_*") but I
don't know why you'd want to do that with the same layout.
If you call .Layout multiple times it'll generate views for each
combination. That's if you want to precompile several themes I
suppose.
example of precompile/reloadable thinking:
http://dev.dejardin.org/trac/spark/browser/trunk/src/Samples/AspNetMvc/AspNetMvc.CompileOnStart/Global.cs
If you follow the link there's also some sample code for how you could
save the precompiled assembly in dev, and load it in production if
it's deployed with the web app. Reloading an asseembly is not impl
yet- that'll take some more work because the view classes will need to
have an attribute added which will allow spark to re-create the
SparkViewDescriptor the view should be used for.