{ "info": { "author": "Pooya Eghbali", "author_email": "persian.writer@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# OOHTML\r\nObject Oriented HTML Construction Toolkit for Python\r\n\r\nSimple Usage\r\n============\r\n\r\nyou can construct HTML in two ways, first with feeding the Constructor::\r\n\r\n >>> from OOHTML import *\r\n >>> C = Constructor()\r\n >>> C.feed(o('html'), #open HTML tag\r\n o('head'), #open Head\r\n c('head'), #close Head\r\n o('body'),\r\n o('div'),\r\n r('Hello World!'), #raw content\r\n s('area'), #singleton (self closing element)\r\n c('div'),\r\n c('body'),\r\n c('html'))\r\n\r\nOr using class methods, the above example can be rewriten as::\r\n\r\n >>> from OOHTML import *\r\n >>> C = Constructor()\r\n >>> C.open('html').open('head').close('head').open('body')\r\n >>> C.open('div').raw('Hello World!').single('area').close('div')\r\n >>> C.close('body').close('html')\r\n\r\nto render the constructor as html, you can use render() method::\r\n\r\n >>> C.render()\r\n\r\nEach of opening, singleton or raw elements can have an id (not the HTML ID of the element) so they can be accessible::\r\n\r\n >>> R = r('Hello World', 'message') #a raw element with id 'message'\r\n >>> O = o('div', {}, 'menu') #opening element with id 'menu'\r\n >>> S = s('img', {}, 'bg') #singleton with id 'bg'\r\n >>> C.feed(R)\r\n >>> C.getElementById('message')\r\n >>> C.removeElementById('message')\r\n \r\nYou can insert a Constructor object inside another Constructor::\r\n\r\n >>> sampleConstructor = Constructor()\r\n >>> C.addAfterId('sampleID', sampleConstructor)\r\n\r\nThere are numerous methods for accessing elements and changing its data::\r\n\r\n >>> C.getElementById('message').value #Raw elements use .value to store their data\r\n >>> C.getElementById('sample').attributes #Opening and Singleton elements have .attribute\r\n >>> C.getElementById('sample').tag #Opening, Closing & Singleton elements have .tag\r\n >>> C.getElementById('sample').id #All elements have .id\r\n\r\nOpening and Singleton Elements can have attributes::\r\n\r\n >>> div = o('div', {'class':['message', 'floater']}, 'contents')\r\n >>> C.feed(div)\r\n >>> div.addAtributes({'id': ['sample']})\r\n\r\nYou can use this attributes to select elements::\r\n\r\n >>> C.getElementsByAttributes({'class': ['test']}) #This returns a generator\r\n \r\nTo show you an example::\r\n\r\n >>> from OOHTML import *\r\n >>> C = Constructor()\r\n \r\n >>> C.feed(o('html'),\r\n o('head'),\r\n o('script', {'type': ['text/javascript'], 'src':['script.js']}),\r\n c('script'),\r\n o('style', {'type': ['text/css'], 'src':['style.css']}),\r\n c('style'),\r\n c('head'),\r\n o('body'),\r\n o('div', {'class':['message']}),\r\n r('Hello World!!!', 'message'),\r\n s('img', {'alt': ['Hello'], 'src':['img.jpeg']}),\r\n c('div'),\r\n o('div', {'class':['message', 'floater']}, 'contents'), c('div'),\r\n c('body'),\r\n c('html'))\r\n \r\n >>> C.getElementById('message').value = \"HTML CONSTRUCTOR!!!\"\r\n >>> C.addAfterId('contents', Constructor().open('div').raw('OOHTML').single('br').close('div'))\r\n >>> print(C.render())\r\n\r\nThe above outputs::\r\n\r\n \r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\nExplore source code for more info.\r\n\r\nDownload\r\n========\r\n\r\nDownload package from here: https://pypi.python.org/pypi/OOHTML or simply install with pip install OOHTML\r\n\r\nProject Info\r\n============\r\n\r\nGithub project page: https://github.com/pooya-eghbali/OOHTML\r\nPyPi: https://pypi.python.org/pypi/OOHTML\r\nMail me at: persian.writer [at] Gmail.com", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pooya-eghbali/OOHTML", "keywords": "HTML Constructor,HTML,Template,HTML Template", "license": "GPLv3", "maintainer": "", "maintainer_email": "", "name": "OOHTML", "package_url": "https://pypi.org/project/OOHTML/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/OOHTML/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/pooya-eghbali/OOHTML" }, "release_url": "https://pypi.org/project/OOHTML/0.1/", "requires_dist": null, "requires_python": null, "summary": "Object Oriented HTML Construction Toolkit for Python", "version": "0.1" }, "last_serial": 1501383, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d6cf9c38b5c64b3b3f4f4ee3bbf210c1", "sha256": "483f0a1c582b467bb42d42361edceb64e4e654124e117f03da8339b537f26ed0" }, "downloads": -1, "filename": "OOHTML-0.1.zip", "has_sig": false, "md5_digest": "d6cf9c38b5c64b3b3f4f4ee3bbf210c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1861, "upload_time": "2015-04-11T16:18:07", "url": "https://files.pythonhosted.org/packages/da/de/eb45c92eaa49e096139fcbd8b005f5e24ea99f934b6fc0393e8fbf0c65e9/OOHTML-0.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d6cf9c38b5c64b3b3f4f4ee3bbf210c1", "sha256": "483f0a1c582b467bb42d42361edceb64e4e654124e117f03da8339b537f26ed0" }, "downloads": -1, "filename": "OOHTML-0.1.zip", "has_sig": false, "md5_digest": "d6cf9c38b5c64b3b3f4f4ee3bbf210c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1861, "upload_time": "2015-04-11T16:18:07", "url": "https://files.pythonhosted.org/packages/da/de/eb45c92eaa49e096139fcbd8b005f5e24ea99f934b6fc0393e8fbf0c65e9/OOHTML-0.1.zip" } ] }