/// <summary>
    /// Renders script for custom transformation.
    /// </summary>
    /// <param name="renderer">Instance of Strands script renderer</param>
    /// <param name="template">Selected template</param>
    /// <exception cref="StrandsException">Transformation does not exist</exception>
    private void RenderCustomTransformation(StrandsScriptRenderer renderer, StrandsWebTemplateData template)
    {
        var transformation = TransformationInfoProvider.GetTransformation(CustomTransformation);

        if (transformation == null)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Cannot load the transformation specified in the web part.", ResHelper.GetString("strands.recommendations.transformations.errorloadingtransformation"));
        }
        if (transformation.TransformationType != TransformationTypeEnum.jQuery)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Transformation type has to be of type jQuery.", ResHelper.GetString("strands.recommendations.transformations.wrongtype"));
        }

        renderer.RenderCustomizedRendererScript(transformation, template.ID, strandsRecs.ClientID);
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        try
        {
            // Generate Strands javascript library code
            StrandsScriptRenderer renderer = new StrandsScriptRenderer(Page, StrandsSettings.GetApiID(SiteContext.CurrentSiteName));
            renderer.RenderCultureScript(DocumentContext.CurrentDocumentCulture.CultureCode);

            if (ECommerceContext.CurrentCurrency != null)
            {
                renderer.RenderCurrencyScript(ECommerceContext.CurrentCurrency.CurrencyCode);
            }

            renderer.RenderLibraryScript();

            var template = ParseRecommendationTemplate(RecommendationID);

            if (UseCustomTransformation())
            {
                RenderCustomTransformation(renderer, template);
            }

            // Sets template as tpl attribute in Strands div element. Strands portal uses it to determine, what recommendation template should be loaded.
            strandsRecs.Attributes.Add("tpl", template.ID);

            FillTemplateAttributes(template.Type);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Strands Recommender", "STRANDS", ex);

            if (ex is StrandsException)
            {
                HandleError(((StrandsException)ex).UIMessage);
            }
            else
            {
                HandleError(ex.Message);
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        try
        {
            // Generate Strands javascript library code
            StrandsScriptRenderer renderer = new StrandsScriptRenderer(Page, StrandsSettings.GetApiID(SiteContext.CurrentSiteName));
            renderer.RenderCultureScript(DocumentContext.CurrentDocumentCulture.CultureCode);

            if (ECommerceContext.CurrentCurrency != null)
            {
                renderer.RenderCurrencyScript(ECommerceContext.CurrentCurrency.CurrencyCode);
            }

            renderer.RenderLibraryScript();

            var template = ParseRecommendationTemplate(RecommendationID);

            if (UseCustomTransformation())
            {
                RenderCustomTransformation(renderer, template);
            }

            // Sets template as tpl attribute in Strands div element. Strands portal uses it to determine, what recommendation template should be loaded.
            strandsRecs.Attributes.Add("tpl", template.ID);

            FillTemplateAttributes(template.Type);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("Strands Recommender", "STRANDS", ex);

            if (ex is StrandsException)
            {
                HandleError(((StrandsException)ex).UIMessage);
            }
            else
            {
                HandleError(ex.Message);
            }
        }
    }
    /// <summary>
    /// Renders script for custom transformation.
    /// </summary>
    /// <param name="renderer">Instance of Strands script renderer</param>
    /// <param name="template">Selected template</param>
    /// <exception cref="StrandsException">Transformation does not exist</exception>
    private void RenderCustomTransformation(StrandsScriptRenderer renderer, StrandsWebTemplateData template)
    {
        var transformation = TransformationInfoProvider.GetTransformation(CustomTransformation);

        if (transformation == null)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Cannot load the transformation specified in the web part.", ResHelper.GetString("strands.recommendations.transformations.errorloadingtransformation"));
        }
        if (transformation.TransformationType != TransformationTypeEnum.jQuery)
        {
            throw new StrandsException("[StrandsRecommendations.ParseRecommendationTemplate]: Transformation type has to be of type jQuery.", ResHelper.GetString("strands.recommendations.transformations.wrongtype"));
        }

        renderer.RenderCustomizedRendererScript(transformation, template.ID, strandsRecs.ClientID);
    }