Beispiel #1
0
 public void TestOutputInRaw()
 {
     Helper.AssertTemplateResult("<< test >>",
                                 "{% raw %}<< test >>{% endraw %}");
 }
Beispiel #2
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);
        }
Beispiel #3
0
 public void TestRawAndFollowing()
 {
     Helper.AssertTemplateResult("{{ test }}65",
                                 "{% raw %}{{ test }}{% endraw %}6{{ 5 }}");
 }
Beispiel #4
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%}");
 }
Beispiel #5
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);
        }
Beispiel #6
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);
        }
Beispiel #7
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" })));
 }
Beispiel #8
0
 public void TestAssignWithDrop()
 {
     Helper.AssertTemplateResult(".MyValue.", @"{% assign foo = value %}.{{ foo.my_property }}.",
                                 Hash.FromAnonymousObject(new { value = new AssignDrop() }));
 }
Beispiel #9
0
 public void TestIf()
 {
     Helper.AssertTemplateResult("  ", " {% if false %} this text should not go into the output {% endif %} ");
     Helper.AssertTemplateResult("  this text should go into the output  ", " {% if true %} this text should go into the output {% endif %} ");
     Helper.AssertTemplateResult("  you rock ?", "{% if false %} you suck {% endif %} {% if true %} you rock {% endif %}?");
 }
Beispiel #10
0
 public void TestAssignDecimalInlineWithInvariantDecimalSeparatorInFrenchCulture()
 {
     Helper.AssertTemplateResult(string.Format("2{0}5", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator),
                                 "{% assign foo = 2.5 %}{{ foo }}");
 }
Beispiel #11
0
 public void TestAssignWithFilter()
 {
     Helper.AssertTemplateResult(".bar.", "{% assign foo = values | split: ',' %}.{{ foo[1] }}.",
                                 Hash.FromAnonymousObject(new { values = "foo,bar,baz" }));
 }
Beispiel #12
0
 public void TestAssignDecimalInlineWithEnglishGroupSeparator()
 {
     Helper.AssertTemplateResult("2500",
                                 "{% assign foo = 2,500 %}{{ foo }}");
 }
Beispiel #13
0
 public void TestAssignDecimal()
 {
     Helper.AssertTemplateResult(string.Format("10{0}05", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator),
                                 "{% assign foo = decimal %}{{ foo }}",
                                 Hash.FromAnonymousObject(new { @decimal = 10.05d }));
 }
Beispiel #14
0
        public void TestAssignMinus()
        {
            Hash assigns = Hash.FromAnonymousObject(new { notused = "content" });

            Helper.AssertTemplateResult("var2:  var2:-1", "var2:{{var2}} {% assign var2 = -1 %} var2:{{var2}}", assigns);
        }
Beispiel #15
0
 public void TestForAndIf()
 {
     Helper.AssertTemplateResult("+--", "{%for item in array%}{% if forloop.first %}+{% else %}-{% endif %}{%endfor%}",
                                 Hash.FromAnonymousObject(new { array = new[] { 1, 2, 3 } }));
 }
Beispiel #16
0
 public void TestSyntaxErrorNoVariable()
 {
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% if jerry == 1 %}"));
 }
Beispiel #17
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);
        }
Beispiel #18
0
 public void TestSyntaxErrorNoExpression()
 {
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% if %}"));
 }
Beispiel #19
0
        public void TestAssign()
        {
            Hash assigns = Hash.FromAnonymousObject(new { var = "content" });

            Helper.AssertTemplateResult("var2:  var2:content", "var2:{{var2}} {%assign var2 = var%} var2:{{var2}}", assigns);
        }
Beispiel #20
0
 public void TestIfElse()
 {
     Helper.AssertTemplateResult(" YES ", "{% if false %} NO {% else %} YES {% endif %}");
     Helper.AssertTemplateResult(" YES ", "{% if true %} YES {% else %} NO {% endif %}");
     Helper.AssertTemplateResult(" YES ", "{% if 'foo' %} YES {% else %} NO {% endif %}");
 }
Beispiel #21
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()));
 }
Beispiel #22
0
 public void TestIfBoolean()
 {
     Helper.AssertTemplateResult(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = true }));
 }
Beispiel #23
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' %}");
 }
Beispiel #24
0
 public void TestIfAnd()
 {
     Helper.AssertTemplateResult(" YES ", "{% if true and true %} YES {% endif %}");
     Helper.AssertTemplateResult("", "{% if false and true %} YES {% endif %}");
     Helper.AssertTemplateResult("", "{% if false and true %} YES {% endif %}");
 }
Beispiel #25
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);
        }
Beispiel #26
0
 public void TestHashMissGeneratesFalse()
 {
     Helper.AssertTemplateResult("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = new Hash() }));
 }
Beispiel #27
0
 public void TestOutputInRaw()
 {
     Helper.AssertTemplateResult("{{ test }}",
                                 "{% raw %}{{ test }}{% endraw %}");
 }
Beispiel #28
0
 public void TestForWithRange()
 {
     Helper.AssertTemplateResult(" 1  2  3 ", "{%for item in (1..3) %} {{item}} {%endfor%}");
 }
Beispiel #29
0
 public void TestTagInRaw()
 {
     Helper.AssertTemplateResult("{% comment %} test {% endcomment %}",
                                 "{% raw %}{% comment %} test {% endcomment %}{% endraw %}");
 }
Beispiel #30
0
 public void TestMultilineTag()
 {
     Helper.AssertTemplateResult("0 1 2 3", "0{%\nfor i in (1..3)\n%} {{\ni\n}}{%\nendfor\n%}");
     //Helper.AssertTemplateResult("0 1 2 3", "0{%for i in (1..3)%}{{i}}{%endfor%}");
 }