public void TestAssignWithFilter()
 {
     Helper.AssertTemplateResult(".bar.", "{% assign foo = values | split: ',' %}.{{ foo[1] }}.",
                                 Hash.FromAnonymousObject(new { values = "foo,bar,baz" }));
 }
 public void TestAssignDecimalInlineWithEnglishGroupSeparator()
 {
     Helper.AssertTemplateResult("2500",
                                 "{% assign foo = 2,500 %}{{ foo }}");
 }
 public void TestAssignDecimalInlineWithInvariantDecimalSeparatorInFrenchCulture()
 {
     Helper.AssertTemplateResult(string.Format("2{0}5", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator),
                                 "{% assign foo = 2.5 %}{{ foo }}");
 }
Exemple #4
0
 public void TestForWithRange()
 {
     Helper.AssertTemplateResult(" 1  2  3 ", "{%for item in (1..3) %} {{item}} {%endfor%}");
 }
 public void TestAssignDecimal()
 {
     Helper.AssertTemplateResult(string.Format("10{0}05", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator),
                                 "{% assign foo = decimal %}{{ foo }}",
                                 Hash.FromAnonymousObject(new { @decimal = 10.05d }));
 }
Exemple #6
0
        public void TestSizeOfHash()
        {
            Hash assigns = Hash.FromAnonymousObject(new { hash = Hash.FromAnonymousObject(new { a = 1, b = 2, c = 3, d = 4 }) });

            Helper.AssertTemplateResult("hash has 4 elements", "hash has {{ hash.size }} elements", assigns);
        }
Exemple #7
0
        public void TestForReversed()
        {
            Hash assigns = Hash.FromAnonymousObject(new { array = new[] { 1, 2, 3 } });

            Helper.AssertTemplateResult("321", "{%for item in array reversed %}{{item}}{%endfor%}", assigns);
        }
Exemple #8
0
 public void TestMultipleNamedCycles()
 {
     Helper.AssertTemplateResult("one one two two one one",
                                 "{%cycle 1: 'one', 'two' %} {%cycle 2: 'one', 'two' %} {%cycle 1: 'one', 'two' %} {%cycle 2: 'one', 'two' %} {%cycle 1: 'one', 'two' %} {%cycle 2: 'one', 'two' %}");
 }
Exemple #9
0
        public void TestSizeOfArray()
        {
            Hash assigns = Hash.FromAnonymousObject(new { array = new[] { 1, 2, 3, 4 } });

            Helper.AssertTemplateResult("array has 4 elements", "array has {{ array.size }} elements", assigns);
        }
Exemple #10
0
 public void TestCaseDetectsBadSyntax()
 {
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% case false %}{% when %}true{% endcase %}", new Hash()));
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% case false %}{% huh %}true{% endcase %}", new Hash()));
 }
Exemple #11
0
 public void TestMultipleCycles()
 {
     Helper.AssertTemplateResult("1 2 1 1 2 3 1",
                                 "{%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%} {%cycle 1,2,3%}");
 }
Exemple #12
0
 public void TestCaptureDetectsBadSyntax()
 {
     Assert.Throws <SyntaxException>(() =>
                                     Helper.AssertTemplateResult("content foo content foo ", "{{ var2 }}{% capture %}{{ var }} foo {% endcapture %}{{ var2 }}{{ var2 }}", Hash.FromAnonymousObject(new { var = "content" })));
 }
Exemple #13
0
        public void TestAssign()
        {
            Hash assigns = Hash.FromAnonymousObject(new { var = "content" });

            Helper.AssertTemplateResult("var2:  var2:content", "var2:{{var2}} {%assign var2 = var%} var2:{{var2}}", assigns);
        }
Exemple #14
0
        public void TestOffsetOnly()
        {
            Hash assigns = Hash.FromAnonymousObject(new { array = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 } });

            Helper.AssertTemplateResult("890", "{%for i in array offset:7 %}{{ i }}{%endfor%}", assigns);
        }
Exemple #15
0
        public void TestNestedFor()
        {
            Hash assigns = Hash.FromAnonymousObject(new { array = new[] { new[] { 1, 2 }, new[] { 3, 4 }, new[] { 5, 6 } } });

            Helper.AssertTemplateResult("123456", "{%for item in array%}{%for i in item%}{{ i }}{%endfor%}{%endfor%}", assigns);
        }
Exemple #16
0
 public void TestForAndIf()
 {
     Helper.AssertTemplateResult("+--", "{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}",
                                 Hash.FromAnonymousObject(new { array = new[] { 1, 2, 3 } }));
 }