Package
A package contains the content to publish at some stage in the template processing. Initially, a package being processed by a Page Template contains a Page item and a package for a Component Template contains a Component item. The final output of a Page Template or Component Template must contain an Output variable that contains the content to publish.
- Item types in package
-
The items in a package can have one of several types defined in the
ContentTypeclass. You can set the content type when you add an item to a package, and later retrieve all items of a certain content type. - Item names in package
-
The names of items in a package do not have to be unique. You can create multiple items with the same name in the package and use a stack mechanism (commonly known as Last In, First Out, or LIFO) to distinguish between them. You add an item to package using the
PushItemmethod, making it the first item in the package with that name. All subsequent methods you call that refer to a named item, such asGetByNameandRemove, always return the first item in the package with that name; that is, the item you last pushed onto the package. By callingRemove, you pop the item off the stack. EvaluateExpression-
A
Packagehas anEvaluateExpressionmethod which takes any Templating Expression as a (String) parameter and returns the result of the evaluation. The following example demonstrates howEvaluateExpressionis used:public void Transform(Engine engine, Package package) { // Get the field's value. string fieldProductLink = package.EvaluateExpression("Component.Fields.ProductLink"); package.PushItem("fieldProductLink", package.CreateStringItem(ContentType.Text, fieldProductLink)); }