Skip to main content

A small small package I use to turn some objects into Bootstrap HTML

Project description

Bootstrap Builder

This is just a small lil package to make building HTML with Python hopefully a lil easier.

>>> import bootstrap_builder as bb
>>> page = bb.HTMLPage(title="Bootstrap Builder")  # Make a page containing the head and body and etc
>>>
>>> # Time for navbar
>>> navbar_container = page.new_navbar()
>>> print(navbar_container)  # <nav class="navbar" />
>>> navbar_container['class'].append('navbar-expand-sm')  # Add 'navbar-expand-sm' to the class list
>>> print(navbar_container)  # <nav class="navbar navbar-expand-sm" />
>>> with navbar_container.new_navbar_nav() as navbar:
	_ = navbar.new_navbar_nav_item().new_child('a', 'Index', attrs={'href': '/index', 'class': 'nav-link'})  # You can add attrs inside new_XXX methods if you don't want to do it via __setitem__

>>> print(navbar_container)  # <nav class="navbar navbar-expand-sm" ><ul class="navbar-nav"><li class="nav-item"><a href="/index" class="nav-link">Index</a></li></ul></nav>
>>>
>>> child = page.new_child('div')
>>> child['data-test'] = 'test1'  # Add a new attr
>>> child['class'].append('owo')  # Add a new class
>>> print(child)  # <div data-test="test1" class="owo" />
>>>
>>> # Add some content to the tag
>>> child = page.new_child('div')
>>> _ = child.new_child('p', 'Nested Tag')  # This is a nested tag
>>> print(child)  # <div><p>Nested Tag</p></div>
>>>
>>> # We can also just add plain content
>>> child = page.new_child('div')
>>> _ = child.add_child('p', 'New Child')  # Like .new_child, but doesn't create a new object, just adds it to the object
>>> print(child)  # <div>New Child</div>
>>>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bootstrap-builder-0.0.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bootstrap_builder-0.0.5-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file bootstrap-builder-0.0.5.tar.gz.

File metadata

  • Download URL: bootstrap-builder-0.0.5.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for bootstrap-builder-0.0.5.tar.gz
Algorithm Hash digest
SHA256 1e4bba7aa06bcc4b803ea1ff576ad22eee6d3fe15b2f3b2fc3a0551f2ed73209
MD5 506182a8ca5894bbbbab205943ddd4c6
BLAKE2b-256 21e0dc7885504f2d1059f446d68f0531f49b844903880fde18bfb489e6692918

See more details on using hashes here.

File details

Details for the file bootstrap_builder-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: bootstrap_builder-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for bootstrap_builder-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 06426a1fae5e7490afaa637e1a248045ab069486dcb9b26ab1b36c818a9601c9
MD5 e6b63a85ef2b9fe67b85147a3a06374c
BLAKE2b-256 ea4c605702bb892f9e113757be9f716bd53268c28658cfb6aeb529f27dc02343

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page