Markup generator for Swift that like a DSL.
let m = MarkUp()
let htmlString = m.html.children {
m.head.children {
m.meta(charset: "UTF-8").doNotSpecifyEndTag()
m.meta(name: "description",
content: "Free Web tutorials").doNotSpecifyEndTag()
m.meta(name: "keywords",
content: "HTML, CSS, JavaScript").doNotSpecifyEndTag()
m.meta(name: "author",
content: "John Doe").doNotSpecifyEndTag()
}
m.body.children {
m.p.children {
"All meta information goes inside the head section."
}
}
}
.toString()
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
</head>
<body>
<p>All meta information goes inside the head section.</p>
</body>
</html>
let m = MarkUp()
let htmlString = m.children {
m[dynamicMember: "!DOCTYPE"](https://raw.github.com/coe/MarkUpDynamic/main/html: nil).doNotSpecifyEndTag()
m.html.children {
m.head.children {
m.meta(charset: "UTF-8").doNotSpecifyEndTag()
m.meta(name: "description",
content: "Free Web tutorials").doNotSpecifyEndTag()
m.meta(name: "keywords",
content: "HTML, CSS, JavaScript").doNotSpecifyEndTag()
m.meta(name: "author",
content: "John Doe").doNotSpecifyEndTag()
}
m.body.children {
m.p.children {
"All meta information goes inside the head section."
}
}
}
}
.toString()
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="description" content="Free Web tutorials">
<meta name="keywords" content="HTML, CSS, JavaScript">
<meta name="author" content="John Doe">
</head>
<body>
<p>All meta information goes inside the head section.</p>
</body>
</html>
let m = MarkUp()
let htmlString = m.ๆธ็ฑ็ฎ้ฒ.children {
m.ๆธๅ.children {
"XMLๅ
ฅ้"
}
m.่่
.children {
"็ญไบ"
}
m.ๆธๅ.children {
"็ถใปXMLๅ
ฅ้"
}
m.่่
.children {
"ๅฐๆพ"
}
}
.toString()
<ๆธ็ฑ็ฎ้ฒ>
<ๆธๅ>XMLๅ
ฅ้</ๆธๅ>
<่่
>็ญไบ</่่
>
<ๆธๅ>็ถใปXMLๅ
ฅ้</ๆธๅ>
<่่
>ๅฐๆพ</่่
>
</ๆธ็ฑ็ฎ้ฒ>
let m = MarkUp()
let htmlString = m.children {
m[dynamicMember: "?xml"](https://raw.github.com/coe/MarkUpDynamic/main/version: "1.0",
encoding: "UTF-8").doNotSpecifyEndTag(instead: "?")
m.ๆธ็ฑ(ๅบ็ๆฅ: "2007-10-31").children {
"ใใใฏๆธ็ฑใงใ.... "
}
}
.toString()
<?xml version="1.0" encoding="UTF-8"?>
<ๆธ็ฑ ๅบ็ๆฅ="2007-10-31">ใใใฏๆธ็ฑใงใ.... </ๆธ็ฑ>
Use dynamicallyCall.
let m = MarkUp()
let htmlString = m.form.dynamicallyCall(withKeywordArguments: ["accept-charset": "UTF-8"]).toString()
<form accept-charset="UTF-8"></form>
link |
Stars: 0 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics