SharpDOM - C#网页模板引擎


MS-PL
Windows
C#

软件简介

SharpDOM 可以让你直接使用 C# 的语法来编写网页,举个例子:

下面是一段HTML代码:

<html>  
    <head>  
        <title>Title of the page</title>  
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">  
        <link href="css/style.css" rel="stylesheet" type="text/css">  
        <script href="/JavaScripts/jquery-1.4.2.min.js" type="text/javascript">  
    </head>  
    <body>  
        <div>  
            <h1>Test Form to Test</h1>  
            <form id="Form1" type="post">  
                <label>Parameter</label> =  
                <input type="text">Enter value</input>  
                <input type="submit" text="Submit !" />  
            </form>  
            <div>  
                <p>Textual description of the footer</p>  
                <a href="http://google.com">  
                    <span>You can find us here</span>  
                </a>  
                <div>  
                    Another nested container  
                </div>  
            </div>  
        </div>  
    </body>  
</html>

使用 SharpDOM 来编写的话,就变成了

html[  
    head[  
        title[ "Title of the page" ],  
        meta.attr(http-equiv: "contenttype", content: "html", charset: "utf-8"),  
        link.attr(href: "css/style.css", rel: "stylesheet", type: "css"),  
        script.attr(href:"/JavaScripts/jquery-1.4.2.min.js", type: "javascript")  
    ],  
    body[  
        div[  
            h1[ "Test Form to Test" ],  
            form.attr(id: "Form1", type: "post")[  
                label[ "Parameter" ], "=", input.attr(type:"text", value: "Enter value"), br,  
                input.attr(type: "submit", value: "Submit !")  
            ],  
            div[  
                p[ "Textual description of the footer" ],  
                a.attr(href: "http://google.com" )[  
                    span[ "You can find us here"]  
                ]  
            ],  
            div[ "Another nested container" ]  
        ]  
    ]  
]