The reference to the TOM.NET API is given in the following example:
<%@ Import Namespace="Tridion.ContentManager.Publishing"%> <%! private string ExtraString() { return "Something added by the C# template"; } %> log.Debug("Executing C# template"); if (engine.RenderMode == RenderMode.Publish) { package.GetByName(Package.OutputName).AppendToStringValue(ExtraString()); }
In addition to the above, the following syntax is supported:
<%@Import Namespace="..." %>
Imports a namespace enclosed between quotation marks in a piece of code. Any class that you import must be present in the global assembly cache.
<%! ... %>
Declares methods, constants, and classes for the rest of the code snippet. Ads cannot contain the string "%>". Please note that any classes you create can only reference a piece of code.
<%RunTemplate Template="tcm:1-184-2048" Class="Tridion.Templating.Examples.ExampleTemplateClass"%>
Starts a special unit for building a .NET assembly template, identified by the URI in the Template attribute. This statement is typically generated by the Tridion 2009 SDL itself when loading the .NET assembly to provide access to a specific class in the .NET assembly.
<%@Assembly Name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"%>
Inserts a reference to a non-standard .NET assembly, which must be present in the global assembly cache. Use the fully qualified name of the assembly.
Nickoli Roussakov
source share