Esempio n. 1
0
 public void TestOutputInRaw()
 {
     Helper.AssertTemplateResult("<< test >>",
                                 "{% raw %}<< test >>{% endraw %}");
 }
Esempio n. 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);
        }
Esempio n. 3
0
 public void TestRawAndFollowing()
 {
     Helper.AssertTemplateResult("{{ test }}65",
                                 "{% raw %}{{ test }}{% endraw %}6{{ 5 }}");
 }
Esempio n. 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%}");
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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" })));
 }
Esempio n. 8
0
 public void TestAssignWithDrop()
 {
     Helper.AssertTemplateResult(".MyValue.", @"{% assign foo = value %}.{{ foo.my_property }}.",
                                 Hash.FromAnonymousObject(new { value = new AssignDrop() }));
 }
Esempio n. 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 %}?");
 }
Esempio n. 10
0
 public void TestAssignDecimalInlineWithInvariantDecimalSeparatorInFrenchCulture()
 {
     Helper.AssertTemplateResult(string.Format("2{0}5", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator),
                                 "{% assign foo = 2.5 %}{{ foo }}");
 }
Esempio n. 11
0
 public void TestAssignWithFilter()
 {
     Helper.AssertTemplateResult(".bar.", "{% assign foo = values | split: ',' %}.{{ foo[1] }}.",
                                 Hash.FromAnonymousObject(new { values = "foo,bar,baz" }));
 }
Esempio n. 12
0
 public void TestAssignDecimalInlineWithEnglishGroupSeparator()
 {
     Helper.AssertTemplateResult("2500",
                                 "{% assign foo = 2,500 %}{{ foo }}");
 }
Esempio n. 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 }));
 }
Esempio n. 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);
        }
Esempio n. 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 } }));
 }
Esempio n. 16
0
 public void TestSyntaxErrorNoVariable()
 {
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% if jerry == 1 %}"));
 }
Esempio n. 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);
        }
Esempio n. 18
0
 public void TestSyntaxErrorNoExpression()
 {
     Assert.Throws <SyntaxException>(() => Helper.AssertTemplateResult("", "{% if %}"));
 }
Esempio n. 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);
        }
Esempio n. 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 %}");
 }
Esempio n. 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()));
 }
Esempio n. 22
0
 public void TestIfBoolean()
 {
     Helper.AssertTemplateResult(" YES ", "{% if var %} YES {% endif %}", Hash.FromAnonymousObject(new { var = true }));
 }
Esempio n. 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' %}");
 }
Esempio n. 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 %}");
 }
Esempio n. 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);
        }
Esempio n. 26
0
 public void TestHashMissGeneratesFalse()
 {
     Helper.AssertTemplateResult("", "{% if foo.bar %} NO {% endif %}", Hash.FromAnonymousObject(new { foo = new Hash() }));
 }
Esempio n. 27
0
 public void TestOutputInRaw()
 {
     Helper.AssertTemplateResult("{{ test }}",
                                 "{% raw %}{{ test }}{% endraw %}");
 }
Esempio n. 28
0
 public void TestForWithRange()
 {
     Helper.AssertTemplateResult(" 1  2  3 ", "{%for item in (1..3) %} {{item}} {%endfor%}");
 }
Esempio n. 29
0
 public void TestTagInRaw()
 {
     Helper.AssertTemplateResult("{% comment %} test {% endcomment %}",
                                 "{% raw %}{% comment %} test {% endcomment %}{% endraw %}");
 }
Esempio n. 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%}");
 }