Executing an item in the package as a Dreamweaver Template
tridion, tridion-2011, tridion2009
Solution
I'm afraid that won't be possible on just any item in the `Package`, since the `Engine` expects `Template`s to be based on Tridion items.
If your Template Item is based on a Tridion Item you can probably get pretty far by starting at the `Engine.GetMediator` method. If it isn't, you'll have to find some way to turn it into a valid `Template` object.
Template template = ...
IMediator mediator = engine.GetMediator(template);
mediator.Transform(engine, template, package);
When I have to create a `Component` object from a Tridion-based Item in the Package, I normally do something like this:
Component component = new Component(item.GetAsXmlDocument().DocumentElement,
engine.GetSession);
I haven't tried, but expect that you can do the same for a `Template` - given that you start with a valid Item from the Package representing a Template to begin with. You can probably clone the XML from an existing Item or find some other way to fake it.
If you get this to work, it will work across all registered template types. The `Engine` provides no special treatment for the types that come with Tridion.
Problem
Does anybody know if it is possible in a compound template to use a string item in the package and execute it as if were a dreamweaver template? And whether you apply the same method to other mediators (like razor)? Thanks Mark