Return to Snippet

Revision: 16435
at August 4, 2009 04:50 by jmcd


Initial Code
var people = new[]
                 {
                     new Person("alice", "alice.png"),
                     new Person("Bob", "bob.jpeg"),
                     new Person("Steve", "stevo.png"), 
                 };

var myHtml =
    html._(
        body._(
            ul._(
                person => li._(
                              a.href("/person/" + person.Id)._(
                                  img.src(person.ImageSrc).alt("profile image for " + person.Name)
                                  )
                              )
                ,
                people
                ).RenderIfChildren()
            )
        );


Results in:

<html>
    <body>
        <ul>
            <li>
                <a href="/person/aec76ab4-d5f9-47d7-8b69-698dedc778c3">
                    <img src="alice.png" alt="profile image for alice"/>
                </a>
            </li>
            <li>
                <a href="/person/158fe190-f39f-4786-b4e7-c26341176f64">
                    <img src="bob.jpeg" alt="profile image for Bob"/>
                </a>
            </li>
            <li>
                <a href="/person/cef84458-ce47-4f5f-a853-643fd23212fe">
                    <img src="stevo.png" alt="profile image for Steve"/>
                </a>
            </li>
        </ul>
    </body>
</html>

Initial URL


Initial Description


Initial Title
Experimental HTML Building Fluent Interface

Initial Tags
html

Initial Language
C#