Skip to content

Build html / xhtml with a nice syntax.

License

Notifications You must be signed in to change notification settings

tammoippen/tagic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI PyPi version Python Versions Downloads codestyle black Ruff

tagic

Build html / xhtml with a nice syntax.

Goals

  • generate html / xhtml with a nice syntax
  • have typing support
  • have editor support for arguments, I used MDN as a reference.
  • KISS: no more than generation

Install

> pip install tagic

Example

from tagic.html import *

print(
    html[
      head[
          title["Example Website"],
          meta(
              name="description",
              content="This is an example website build with tagic",
          ),
      ],
      body[
          header(id="header")[h1["Awesome"]],
          main[p["Some text ", span["with tags"], "in between"]],
          footer(hidden=True),
      ],
  ].render(indent=True)
)

Will return

<!DOCTYPE html>
<html>
  <head>
    <title>
      Example Website
    </title>
    <meta content="This is an example website build with tagic" name="description" />
  </head>
  <body>
    <header id="header">
      <h1>
        Awesome
      </h1>
    </header>
    <main>
      <p>
        Some text
        <span>
          with tags
        </span>
        in between
      </p>
    </main>
    <footer hidden>

    </footer>
  </body>
</html>

Similar Projects

  • dominate: missing the typing support and editor support for arguments
  • domonic: to broad of a scope, with parsing, js and style and queries.
  • domini: missing editor support for arguments
  • htmler: missing the typing support and editor support for arguments
  • PyHTML: missing the typing support and editor support for arguments
  • pyhtmlgen: incomplete
  • html: i do not like syntax and missing the typing support and editor support for arguments
  • MarkupPy
  • yattag: i do not like syntax
  • py-microhtml: funny tag names and no editor support for arguments
  • py3html: no editor support for arguments
  • fast-html
  • py2html not in pypi, but i like the syntax and took inspiration