In Tom.Net API for Tridion 2013 SP1 in Engine class for PublishingContext properties there is following remark:
The Publishing Context consists of items in the Tridion.ContentManager.Publishing assembly, and serve as context for the current publishing actions. In case no PublishingContext is available (in practice, when a Template Building Block is being debugged in the Template Builder), the property-value is null.
But when I use following code in c# code fragment
string templateID = engine.PublishingContext.RenderedItem.ResolvedItem.Template.Id.ToString();
I am able to get both Page and Component template ID in following scenarios:
- Tridion Preview
- Template Builder
- XPM fast-track publishing
Is is safe to use code above in order to get Template ID?