예제 #1
0
        public void A_transform_can_be_used_to_add_attributes()
        {
            dynamic _ = new PocketView();

            _.div = PocketView.Transform(
                (tag, model) => tag.HtmlAttributes.Class("foo"));

            string output = _.div("hi").ToString();

            output.Should().Be("<div class=\"foo\">hi</div>");
        }
예제 #2
0
        public void A_transform_merges_differently_named_attributes()
        {
            dynamic _ = new PocketView();

            _.div = PocketView.Transform(
                (tag, model) => tag.HtmlAttributes.Class("foo"));

            string output = _.div[style : "color:red"]("hi").ToString();

            output
            .Should().Be("<div class=\"foo\" style=\"color:red\">hi</div>");
        }
예제 #3
0
        public void A_transform_overwrites_like_named_attributes()
        {
            dynamic _ = new PocketView();

            _.div = PocketView.Transform(
                (tag, model) => tag.HtmlAttributes["style"] = "color:yellow");

            string output = _.div[style : "color:red"]("hi").ToString();

            output
            .Should()
            .Be("<div style=\"color:yellow\">hi</div>");
        }
예제 #4
0
        public void A_transform_can_be_used_to_create_an_alias()
        {
            _.foolink = PocketView.Transform(
                (tag, model) =>
            {
                tag.Name = "a";
                tag.HtmlAttributes.Add("href", "http://foo.biz");
            });

            string output = _.foolink("click here!").ToString();

            output
            .Should()
            .Be("<a href=\"http://foo.biz\">click here!</a>");
        }
예제 #5
0
        public void A_transform_can_be_used_to_create_an_expandable_tag()
        {
            _.textbox = PocketView.Transform(
                (tag, model) =>
            {
                tag.Name    = "div";
                tag.Content = w =>
                {
                    w.Write(label[@for: model.name](model.name));
                    w.Write(input[value: model.value, type: "text", name: model.name]);
                };
            });

            string output = _.textbox(name: "FirstName", value: "Bob").ToString();

            output
            .Should().Be("<div><label for=\"FirstName\">FirstName</label><input name=\"FirstName\" type=\"text\" value=\"Bob\" /></div>");
        }