No description
Find a file
2022-07-19 23:07:06 +02:00
src [add] Export all html tags and tests 2022-07-19 22:56:23 +02:00
tests [add] Export all html tags and tests 2022-07-19 22:56:23 +02:00
.gitignore [add] Move compilation files to /build and ignore it 2022-07-16 00:11:48 +02:00
config.nims [add] Move compilation files to /build and ignore it 2022-07-16 00:11:48 +02:00
LICENSE [add] LICENSE 2022-07-15 12:33:00 +02:00
README.org [add] Some tagger/html docs in README 2022-07-19 23:01:53 +02:00
shell.nix [add] Nix shell with nim-1.6.6 2022-07-15 12:26:31 +02:00
tagger.nimble [add] New lib version 2022-07-19 23:04:49 +02:00

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"