Skip to content

tawesoft/strictdom

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Strictdom

Stictdom is a strictly typed wrapper over Dominate, a Python library for creating and manipulating HTML documents.

Compared to using Dominate directly, strictdom offers:

  • Type hints for code-completion / IntelliSense / IDE hints

  • Type hints and explicit arguments for HTML5 & ARIA conformance at runtime, or at compile-time with mypy.

Features:

  • Nothing new to learn - mostly the same interface as vanilla.

  • Stable versioned interface e.g. strictdom.tags_1 is a frozen view of the spec

  • Consistent handling of both boolean attributes and the weird "boolean-like" attributes like contenteditable or spellcheck.

Example: Vanilla vs Strict

"Vanilla" Dominate

import dominate.tags as dom

print(dom.button("Hello world",
    cls="hello",
    some_invalid_tag="hello",
    onclick="alert('Hello world');"
))

Strictdom

import strictdom.tags_1 as tags

print(tags.button("Hello world",
    class_="hello",
    # some_invalid_tag="hello",
    events=tags.Events(click="alert('Hello world');")
))

some_invalid_tag will raise a runtime error if not removed:

TypeError: __init__() got an unexpected keyword argument 'some_invalid_tag'

Usage

  • Install with sudo pip3 install strictdom --upgrade --no-cache-dir

  • Build from source with python3 make_1.py (requires html5spec) in a sibling directory and test with pytest.

TODO

  • Typechecked ARIA and Event Handlers

About

Strictly typed wrapper around Knio's Dominate, a Python library for creating and manipulating HTML documents

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages