Exemplo n.º 1
0
        public void TestNestedContextDrop()
        {
            string output = Template.Parse(" {{ product.context.foo }} ")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop(), foo = "monkey" }));

            Assert.AreEqual(" monkey ", output);
        }
Exemplo n.º 2
0
        public void TestTextArrayDrop()
        {
            string output = Template.Parse("{% for text in product.texts.array %} {{text}} {% endfor %}")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() }));

            Assert.AreEqual(" text1  text2 ", output);
        }
Exemplo n.º 3
0
        public void TestContextDrop()
        {
            string output = Template.Parse(" {{ context.bar }} ")
                            .Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), bar = "carrot" }));

            Assert.AreEqual(" carrot ", output);
        }
Exemplo n.º 4
0
        public void TestTextDrop2()
        {
            string output = Template.Parse(" {{ product.catchall.unknown }} ")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() }));

            Assert.AreEqual(" method: unknown ", output);
        }
Exemplo n.º 5
0
        public void TestTextDrop()
        {
            string output = Template.Parse(" {{ product.texts.text }} ")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() }));

            Assert.AreEqual(" text1 ", output);
        }
Exemplo n.º 6
0
        public void TestDropDoesNotOutputItself()
        {
            string output = Template.Parse(" {{ product }} ")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() }));

            Assert.AreEqual("  ", output);
        }
Exemplo n.º 7
0
        public void TestProtected()
        {
            string output = Template.Parse(" {{ product.call_me_not }} ")
                            .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() }));

            Assert.AreEqual("  ", output);
        }
Exemplo n.º 8
0
        public void Mytest()
        {
            string output = Template.Parse(" {{ object.any.name }} ")
                            .Render(Hash.FromAnonymousObject(new { @object = new ObjectDrop() }));

            Console.Write(output);
        }
Exemplo n.º 9
0
        public void TestNestedObj()
        {
            Template template = Template.Parse("{{ value.nested.c }}");

            Assert.AreEqual("test", template.Render(Hash.FromAnonymousObject(new
            {
                value = new { name = "hello", test = "test", nested = new { c = "test" } }
            })));
        }
Exemplo n.º 10
0
        public void TestDropWithFilters()
        {
            string output = Template.Parse(" {{ product | product_text }} ")
                            .Render(new RenderParameters
            {
                LocalVariables = Hash.FromAnonymousObject(new { product = new ProductDrop() }),
                Filters        = new[] { typeof(ProductFilter) }
            });

            Assert.AreEqual(" text1 ", output);
        }
Exemplo n.º 11
0
        public void TestJobjectToDotLiquid()
        {
            Template template = Template.Parse("{{ value.name }}");

            Assert.AreEqual("salam", template.Render(Hash.FromAnonymousObject(new
            {
                value = JObject.FromObject(new Boy()
                {
                    Age = 10, Name = "salam"
                }).ToObject <Boy>()
            })));
        }
Exemplo n.º 12
0
 public void TestScopeThroughProc()
 {
     Assert.AreEqual("1", Template.Parse("{{ s }}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), s = (Proc)(c => c["context.scopes"]) })));
     Assert.AreEqual("2", Template.Parse("{%for i in dummy%}{{ s }}{%endfor%}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), s = (Proc)(c => c["context.scopes"]), dummy = new[] { 1 } })));
     Assert.AreEqual("3", Template.Parse("{%for i in dummy%}{%for i in dummy%}{{ s }}{%endfor%}{%endfor%}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), s = (Proc)(c => c["context.scopes"]), dummy = new[] { 1 } })));
 }
Exemplo n.º 13
0
        public void TestRubyNamingConventionPrintsHelpfulErrorIfMissingPropertyWouldMatchCSharpNamingConvention()
        {
            INamingConvention savedNamingConvention = Template.NamingConvention;

            Template.NamingConvention = new RubyNamingConvention();
            Template template = Template.Parse("{{ value.ProductID }}");

            Assert.AreEqual("Missing property. Did you mean 'product_id'?", template.Render(Hash.FromAnonymousObject(new
            {
                value = new CamelCaseDrop()
            })));
            Template.NamingConvention = savedNamingConvention;
        }
Exemplo n.º 14
0
 public void TestNullCatchAll()
 {
     Assert.AreEqual("", Template.Parse("{{ nulldrop.a_method }}").Render(Hash.FromAnonymousObject(new { nulldrop = new NullDrop() })));
 }
Exemplo n.º 15
0
 public void TestEnumerableDropSize()
 {
     Assert.AreEqual("3", Template.Parse("{{collection.size}}").Render(Hash.FromAnonymousObject(new { collection = new EnumerableDrop() })));
 }
Exemplo n.º 16
0
 public void TestEnumerableDrop()
 {
     Assert.AreEqual("123", Template.Parse("{% for c in collection %}{{c}}{% endfor %}").Render(Hash.FromAnonymousObject(new { collection = new EnumerableDrop() })));
 }
Exemplo n.º 17
0
 public void TestAccessContextFromDrop()
 {
     Assert.AreEqual("123", Template.Parse("{% for a in dummy %}{{ context.loop_pos }}{% endfor %}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), dummy = new[] { 1, 2, 3 } })));
 }
Exemplo n.º 18
0
 public void TestScopeFromTags()
 {
     Assert.AreEqual("1", Template.Parse("{% for i in context.scopes_as_array %}{{i}}{% endfor %}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), dummy = new[] { 1 } })));
     Assert.AreEqual("12", Template.Parse("{%for a in dummy%}{% for i in context.scopes_as_array %}{{i}}{% endfor %}{% endfor %}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), dummy = new[] { 1 } })));
     Assert.AreEqual("123", Template.Parse("{%for a in dummy%}{%for a in dummy%}{% for i in context.scopes_as_array %}{{i}}{% endfor %}{% endfor %}{% endfor %}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), dummy = new[] { 1 } })));
 }
Exemplo n.º 19
0
 public void TestScopeWithAssigns()
 {
     Assert.AreEqual("variable", Template.Parse("{% assign a = 'variable'%}{{a}}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop() })));
     Assert.AreEqual("variable", Template.Parse("{% assign a = 'variable'%}{%for i in dummy%}{{a}}{%endfor%}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), dummy = new[] { 1 } })));
     Assert.AreEqual("test", Template.Parse("{% assign header_gif = \"test\"%}{{header_gif}}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop() })));
     Assert.AreEqual("test", Template.Parse("{% assign header_gif = 'test'%}{{header_gif}}").Render(Hash.FromAnonymousObject(new { context = new ContextDrop() })));
 }