public void TestNestedContextDrop() { string output = Template.Parse(" {{ product.context.foo }} ") .Render(Hash.FromAnonymousObject(new { product = new ProductDrop(), foo = "monkey" })); Assert.AreEqual(" monkey ", output); }
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); }
public void TestContextDrop() { string output = Template.Parse(" {{ context.bar }} ") .Render(Hash.FromAnonymousObject(new { context = new ContextDrop(), bar = "carrot" })); Assert.AreEqual(" carrot ", output); }
public void TestTextDrop2() { string output = Template.Parse(" {{ product.catchall.unknown }} ") .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() })); Assert.AreEqual(" method: unknown ", output); }
public void TestTextDrop() { string output = Template.Parse(" {{ product.texts.text }} ") .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() })); Assert.AreEqual(" text1 ", output); }
public void TestDropDoesNotOutputItself() { string output = Template.Parse(" {{ product }} ") .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() })); Assert.AreEqual(" ", output); }
public void TestProtected() { string output = Template.Parse(" {{ product.call_me_not }} ") .Render(Hash.FromAnonymousObject(new { product = new ProductDrop() })); Assert.AreEqual(" ", output); }
public void Mytest() { string output = Template.Parse(" {{ object.any.name }} ") .Render(Hash.FromAnonymousObject(new { @object = new ObjectDrop() })); Console.Write(output); }
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" } } }))); }
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); }
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>() }))); }
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 } }))); }
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; }
public void TestNullCatchAll() { Assert.AreEqual("", Template.Parse("{{ nulldrop.a_method }}").Render(Hash.FromAnonymousObject(new { nulldrop = new NullDrop() }))); }
public void TestEnumerableDropSize() { Assert.AreEqual("3", Template.Parse("{{collection.size}}").Render(Hash.FromAnonymousObject(new { collection = new EnumerableDrop() }))); }
public void TestEnumerableDrop() { Assert.AreEqual("123", Template.Parse("{% for c in collection %}{{c}}{% endfor %}").Render(Hash.FromAnonymousObject(new { collection = new EnumerableDrop() }))); }
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 } }))); }
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 } }))); }
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() }))); }