Changes

Jump to: navigation, search

Libhtml

1,603 bytes added, 17:28, 1 April 2009
Html.page
;body
:reference to body object
 
== Properties ==
 
The Html class exposes three properties which correspond to the three sections of a standard HTML tagset and can be used to manipulate them:
 
;tag
:returns a reference to the tag defined for this object
 
;attr
:returns a reference to the attributes inside the opening tag, if any.
 
;inside
:returns a reference to the contents of the tagset as a list -- that is, whatever exists between the opening and closing tags.
 
==== Examples ====
 
#Retrieve the tag name of an Html object:
>>> html = Html('html')
>>> html
['<html>', '</html>']
>>> html.tag
'html'
>>>
 
#Change the tag name:
>>> html.tag = 'tail'
>>> html
['<tail>', '</tail>']
>>>
 
#Retrieve the tag attributes:
>>> a = Html('a', href='http://cnn.org')
>>> a
['<a href="http://cnn.org">', '</a>']
>>> a.attr
'href="http://cnn.org"'
>>>
 
#Change the tag attributes:
>>> a.attr
'href="http://gramps-project.org"'
>>>
 
#Extend the tag attributes:
>>> a.attr += ' id="myhref"'
>>> a.attr
'href="http://gramps-project.org" id="myhref"'
>>>
 
#Delete the tag attributes:
>>> del a.attr
>>> a.attr
''
>>>
 
#Retrieve whatever is inside a tag:
>>> p = Html('p','This is a paragraph')
>>> p.inside
['This is a paragraph']
>>>
 
#Change whatever is inside a tag:
>>> p.inside = "This is a better paragraph"
>>> p.inside
['This is a better paragraph']
>>>
 
#Extend whatever is inside a tag:
>>> p.inside += ["THIS IS THE BEST PARAGRAPH!"]
>>> p.inside
['This is a better paragraph', 'THIS IS THE BEST PARAGRAPH!']
>>>
 
#Delete whatever is inside a tag:
>>> del p.inside
>>> p.inside
[]
>>> p
70
edits

Navigation menu