public void Transform(Engine engine, Package package)
        {
            this.package = package;
            this.engine  = engine;

            if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
            {
                if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
                {
                    log.Debug("template is rendered by a DynamicDelivery page template, will not convert to lower case");
                    return;
                }
            }

            Item   outputItem = package.GetByName("Output");
            String inputValue = package.GetValue("Output");

            if (inputValue == null || inputValue.Length == 0)
            {
                log.Error("Could not find 'Output' in the package. Exiting template.");
                return;
            }

            string convertedValue = LowerCaseConverter.Convert(inputValue);

            package.Remove(outputItem);
            outputItem.SetAsString(convertedValue);
            package.PushItem("Output", outputItem);
        }
        public void Transform(Engine engine, Package package)
        {
            this.package = package;
            this.engine  = engine;

            if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery))
            {
                if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery))
                {
                    log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java");
                    return;
                }
            }

            Item   outputItem = package.GetByName("Output");
            String inputValue = package.GetValue("Output");

            if (inputValue == null || inputValue.Length == 0)
            {
                log.Warning("Could not find 'Output' in the package, nothing to transform");
                return;
            }

            // Combine the 'to lower' and 'to java' functions, since there is no reason to have one without the other.
            // Note: it is still possible (for backwards compatibility) to have a separate ToLower TBB in your templates.
            // In that case, the first letter of each element will be converted into lower case twice, which doesn't do any harm.
            string outputValue = LowerCaseConverter.Convert(inputValue);

            outputValue = XmlToJavaConverter.Convert(outputValue);
            // outputValue = XmlMinimizer.Convert(outputValue);

            // replace the Output item in the package
            package.Remove(outputItem);
            outputItem.SetAsString(outputValue);
            package.PushItem("Output", outputItem);
        }
예제 #3
0
 public void LowerCaseConverterShouldWork()
 {
     var s = "hsDkjdsa8dask";
     var converter = new LowerCaseConverter();
     Assert.AreEqual(s.ToLower(), (string)converter.Convert(s, typeof(bool), null, CultureInfo.CurrentCulture));            
 }
예제 #4
0
 public void SetUp()
 {
     lowerCaseConverter = new LowerCaseConverter();
 }
예제 #5
0
        public void Convert_ReturnsLowercaseWord(string word, string expected)
        {
            var converter = new LowerCaseConverter();

            converter.Convert(word).Should().Be(expected);
        }