Skip to content

jeffa/HTML-Auto-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTML-Auto (python)

Just another HTML tag generator for Python. pypi package Build Status

Description

Generate HTML tags with ease (HTML4, HTML5, XHTML and SVG).

Synopsis

from HTML.Auto import Tag
auto = Tag({ 'indent': '    ' })

print( auto.tag({ 'tag': 'hr' }) )
print( auto.tag({ 'tag': 'h1', 'cdata': 'heading' }) )
print( auto.tag({ 'tag': 'p', 'cdata': 'paragraph', 'attr': { 'class': 'para' } }) )

attr = { 'style': { 'color': [ 'red', 'green' ] } }
print(
    auto.tag({
        'tag': 'ol',
        'attr': { 'reversed': 'reversed' },
        'cdata': [ list(map((lambda d: { 'tag': 'li', 'attr': attr, 'cdata': d }), [1,2,3,4,5])) ]
    })
)

tr_attr = { 'class': [ 'odd', 'even' ] }
print(
    auto.tag({
        'tag': 'table',
        'attr': { 'class': 'spreadsheet' },
        'cdata': [
            {
                'tag': 'tr',
                'attr': tr_attr,
                'cdata': {
                    'tag': 'th',
                    'attr': { 'style': { 'color': [ 'red', 'green' ] } },
                    'cdata': [ 'one', 'two', 'three' ],
                },
            },
            {
                'tag': 'tr',
                'attr': tr_attr,
                'cdata': {
                    'tag': 'td',
                    'attr': { 'style': { 'color': [ 'orange', 'blue' ] } },
                    'cdata': [ 'four', 'five', 'six' ],
                },
            },
            {
                'tag': 'tr',
                'attr': tr_attr,
                'cdata': {
                    'tag': 'td',
                    'attr': { 'style': { 'color': [ 'red', 'green' ] } },
                    'cdata': [ 'seven', 'eight', 'nine' ],
                },
            },
        ]
    })
)

Also includes HTML.Auto.Attr which provides rotating attributes.

from HTML.Auto import Attr

auto = Attr({ 'foo': ['bar','baz','qux'] })

for i in range(4):
    print( str( auto ) ) 

Installation

pip install HTML-Auto

License and Copyright

See License.

About

Just another HTML tag generator (for python).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published