This project is read-only.


Assman supports a plugin architecture through which you can add to and extend the framework. Some examples of what you can do with plugins:
  • Add support for additional scripting languages (e.g. CoffeeScript)
  • Add support for additional styling languages (e.g. dotLess)
  • Add support for your favorite minification library (e.g. YUI)
  • Add support for retrieving scripts or stylesheets from other locations besides the website's filesystem (note that embedded resources are supported out of the box, no need for a plugin)
  • Add a filter to the compilation pipeline to add transformations to the script and/or stylesheet content when it is compiled
  • Add consolidation groups dynamically through code (instead of in the config file)

Developing a plugin

To develop an Assman plugin, you simply need to implement the IAssmanPlugin interface. It has one method: Initialize that takes an AssmanContext object as its parameter. The Initialize method will be called once when the framework initializes itself. AssmanContext is a class where all of the configuration knobs are for the framework. The most interesting methods on the class are:

void ContentFilterPipeline GetContentPipelineForExtension(string fileExtension)

Assman keeps separate ContentFilterPipeline's for each unique file extension. If you want to extend an existing ContentFilterPipeline, you can get access to it via this method. A ContentFilterPipeline is just a pipeline of IContentFilter's. Adding filters to the pipeline will allow you to hook into the compilation process of each resource and add functionality. One example of IContentFilter implementation that comes out of the box with Assman is a CssRelativePathFilter that will update the relative paths to in your .css when the .css file is consolidated into a file that is in a different directory. Another example is a JSMinContentFilter that applies minification to .js files using the JSMin library.

void MapExtensionToContentPipeline(string fileExtension, ContentFilterPipeline filterPipeline)

If you want to create a whole new ContentFilterPipeline, you can use this method to map the pipeline to the given file extension.

void MapExtensionToDependencyProvider(string fileExtension, IDependencyProvider dependencyProvider)

This method allows you to set which IDependencyProvider implementation will be used for a given file extension. If you have a custom way to define dependencies between resources then this will be useful.

void AddFinder(IResourceFinder finder);

AddFinder allows you to add your own implementation of IResourceFinder to discover IResource's that are not "findable" by Assman out of the box. Out of the box, Assman can find resources on the filesystem of the website and in Embedded Resources of assemblies that Assman knows about. IResourceFinder is basically how Assman virtualizes the filesystem.

void AddAssembly(Assembly assembly)

If you have scripts or stylesheets that are embedded resources in an assembly, then Assman needs to know to look for them in that assembly. You can do that by adding your assembly to the <assemblies> section of the Assman.config file, or in code by calling the AddAssembly method.

Last edited May 30, 2011 at 8:46 PM by andyalm, version 2


No comments yet.