Changes

Jump to: navigation, search

Libhtml

4 bytes added, 16:40, 1 April 2009
Object instantiation
The constructor accepts the following arguments:
;tag :The HTML tag to be used. This defaults to 'html.' The constructor does not validate the tag, so anything is accepted.arg1...argn Optional positional arguments. These arguments will be copied as is between the opening and closing tags.attr tag attributes that violate Python syntax so cannot be passed as "keyword=arg" (See below). An example would be the xml:lang attritube, which will cause a syntax error if given as a keyword parameter.indent Indent this object with respect to its parent, if parent exists. Default = True. Note that the indentation is cumulative. That is, the indentation of this object will be the sum of its indentation and that of its parent, if the parent is indented. This is useful for producing human-readable output though it should have no effect on browsers rendering the page.inline Instruct the write() method to output the tag and all its contents (including any nested elements) as one string. Default is False which means call the output method once for the beginning and ending tags and once for each element contained therein, including sub-elements.close This element should be closed normally (e.g. <tag>...</tag>). Default is True.keyword1=arg1... Any other keywords are passed into the tag. That is, they are assumed to be tag attributes.
;arg1...argn:Optional positional arguments. These arguments will be copied as is between the opening and closing tags. ;attr:tag attributes that violate Python syntax so cannot be passed as "keyword=arg" (See below). An example would be the xml:lang attritube, which will cause a syntax error if given as a keyword parameter. ;indent:Indent this object with respect to its parent, if parent exists. Default = True. Note that the indentation is cumulative. That is, the indentation of this object will be the sum of its indentation and that of its parent, if the parent is indented. This is useful for producing human-readable output though it should have no effect on browsers rendering the page. ;inline:Instruct the write() method to output the tag and all its contents (including any nested elements) as one string. Default is False which means call the output method once for the beginning and ending tags and once for each element contained therein, including sub-elements. ;close:This element should be closed normally (e.g. <tag>...</tag>). Default is True. ;keyword1=arg1...:Any other keywords are passed into the tag. That is, they are assumed to be tag attributes. '''Note 1: ''' There are several tags that are not normally closed. These include: area, base, br, frame, hr, image, input, link, meta and param. The constructor recognizes these and assumes close=False, which means that the tags are closed automatically. For example, "meta" is automatically closed like this:
<meta ... />
'''Note 2: ''' At least one typical tag attribute, "class=" conflicts with a Python keyword. To circumvent this, the constructor will see if a keyword has a trailing underscore ("_"). If so, it will strip the underscore and pass the resulting keyword assignment into the tag. 
=== Extending your Html objects ===
70
edits

Navigation menu