SharpDOMC#网页模板引擎

联合创作 · 2023-09-29 02:31

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" ]
]
]
]
浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报