register macros/renderers per WikiEngine instance


Besides having static macros/renderers, I think it would be usefull to have macros/renderers registered within the WikiEngine instance (per object instance, not static). For example, I have an application which renders different syntax in different places, so I need different configurations within the same thread. Also, I think this option would make it easier to configure the WikiEngine using DI containers.

Maybe I'm missing something and this feature is already possible with the current code.

PS: Excelent project! Keep it going!
Closed Nov 17, 2010 at 10:58 PM by matthaw
Released in version 2.0


matthaw wrote Mar 3, 2010 at 2:26 PM

Before I close this, would you be able to use the overload for Render that takes in an IEnumerable<IMacro>?

The basic use, would be:

var macros = new IMacro[] {new CustomMacro()};
IEnumerable<IMacro> allMacros = Macros.All.Union(macros);
engine.Render(content, allMacros);

michaelstum wrote Mar 24, 2010 at 7:06 AM

Just my 2 cents: At the moment, Macros and Renders are "asymmetric": For Renderers I need to return a new MacroFormatter that uses .Union with the existing Renderers, while Macros can be thrown into the .Render method.

I would propose having a Contructor/Property on the WikiEngine class that takes IEnumerables for Macros and Renderers and allow Registration/Unregistration on that Instance. That just feels more "symmetric" as often a custom Macro requires a custom Renderer as well.

matthaw wrote Sep 15, 2010 at 4:05 PM

This is now available in the latest source. I added two new overloads to Render that take in an IEnumerable<IRenderer>. So you can now do...

var macros = new IMacro[] {new CustomMacro()};
var renderers = new IRenderer[] {new CustomRenderer()};
engine.Render(content, Macros.All.Union(macros), Renderers.All.Union(renderers));