This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

# OOHTML Object Oriented HTML Construction Toolkit for Python

Simple Usage

you can construct HTML in two ways, first with feeding the Constructor:

>>> from OOHTML import *
>>> C = Constructor()
>>> C.feed(o('html'),                  #open HTML tag
             o('head'),                #open Head
             c('head'),                #close Head
                 r('Hello World!'),    #raw content
                 s('area'),            #singleton (self closing element)

Or using class methods, the above example can be rewriten as:

>>> from OOHTML import *
>>> C = Constructor()
>>>'div').raw('Hello World!').single('area').close('div')
>>> C.close('body').close('html')

to render the constructor as html, you can use render() method:

>>> C.render()

Each of opening, singleton or raw elements can have an id (not the HTML ID of the element) so they can be accessible:

>>> R = r('Hello World', 'message') #a raw element with id 'message'
>>> O = o('div', {}, 'menu')        #opening element with id 'menu'
>>> S = s('img', {}, 'bg')          #singleton with id 'bg'
>>> C.feed(R)
>>> C.getElementById('message')
>>> C.removeElementById('message')

You can insert a Constructor object inside another Constructor:

>>> sampleConstructor = Constructor()
>>> C.addAfterId('sampleID', sampleConstructor)

There are numerous methods for accessing elements and changing its data:

>>> C.getElementById('message').value          #Raw elements use .value to store their data
>>> C.getElementById('sample').attributes      #Opening and Singleton elements have .attribute
>>> C.getElementById('sample').tag             #Opening, Closing & Singleton elements have .tag
>>> C.getElementById('sample').id              #All elements have .id

Opening and Singleton Elements can have attributes:

>>> div = o('div', {'class':['message', 'floater']}, 'contents')
>>> C.feed(div)
>>> div.addAtributes({'id': ['sample']})

You can use this attributes to select elements:

>>> C.getElementsByAttributes({'class': ['test']})    #This returns a generator

To show you an example:

>>> from OOHTML import *
>>> C = Constructor()

>>> C.feed(o('html'),
           o('script', {'type': ['text/javascript'], 'src':['script.js']}),
           o('style', {'type': ['text/css'], 'src':['style.css']}),
           o('div', {'class':['message']}),
             r('Hello World!!!', 'message'),
             s('img', {'alt': ['Hello'], 'src':['img.jpeg']}),
           o('div', {'class':['message', 'floater']}, 'contents'), c('div'),

>>> C.getElementById('message').value = "HTML CONSTRUCTOR!!!"
>>> C.addAfterId('contents', Constructor().open('div').raw('OOHTML').single('br').close('div'))
>>> print(C.render())

The above outputs:

        <script type = "text/javascript" src = "script.js">
        <style type = "text/css" src = "style.css">
        <div class = "message">
            HTML CONSTRUCTOR!!!
            <img src = "img.jpeg" alt = "Hello"/>
        <div class = "message floater">

Explore source code for more info.


Download package from here: or simply install with pip install OOHTML

Project Info

Github project page: PyPi: Mail me at: persian.writer [at]

Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date (1.9 kB) Copy SHA256 Checksum SHA256 Source Apr 11, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting