mirror of
https://github.com/aruZeta/tagger
synced 2026-01-15 05:01:34 +00:00
No description
| src | ||
| tests | ||
| .gitignore | ||
| config.nims | ||
| LICENSE | ||
| README.org | ||
| shell.nix | ||
| tagger.nimble | ||
Tagger, a nim library to write markup tags
Writing some simple xml:
import tagger/tagMacro
createTag contacts
createTag contact, closed = false
let myContacts = contacts:
contact:
name = "Tony"
phone = "654435435"
contact:
name = "Spammer"
phone = "654435436"
echo myContacts
Gives us:
<contacts>
<contact name="Tony" phone="654435435"/>
<contact name="Spammer" phone="654435436"/>
</contacts>
You can also write html with predefined tags:
import tagger/html
let htmlPage = html:
head:
title:
"A simple html page"
body:
hdiv:
p:
"A simple paragraph"
echo htmlPage
Gives us:
<html>
<head>
<title>A simple html page</title>
</head>
<body>
<div>
<p>A simple paragraph</p>
</div>
</body>
</html>
Note: actually writes an obfuscated version (no indentation nor newlines).
Note: when using the html tag macros, some of them happen to be named
the same as some keywords, like div, so in order to avoid this
limitation an h is added at the start (from html), so hdiv.
Note: when defining tag parameters, you may want to write a paramater
which happens to be a reserved keyword, like type or method, in
those cases you just need to surround it with double quotes.
form:
action = "login"
"method" = "post"
input:
"type" = "text"
name = "username"
input:
"type" = "submit"
value = "Login"