{ "info": { "author": "Michael F. Ellis", "author_email": "michael.f.ellis@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*\n\n- [Python htmltree project](#python-htmltree-project)\n\t- [Create and manipulate HTML and CSS from the comfort of Python](#create-and-manipulate-html-and-css-from-the-comfort-of-python)\n\t\t- [Installation](#installation)\n\t\t- [Quick Start](#quick-start)\n\t\t\t- [Open a Python interpreter and type or paste the following](#open-a-python-interpreter-and-type-or-paste-the-following)\n\t\t\t- [Render and print the HTML](#render-and-print-the-html)\n\t\t\t- [Now add some styling and text ...](#now-add-some-styling-and-text)\n\t\t\t- [and print the result.](#and-print-the-result)\n\t\t- [Reserved words and hyphenated attributes](#reserved-words-and-hyphenated-attributes)\n\t\t- [Viewing your work](#viewing-your-work)\n\t- [Discussion](#discussion)\n\t\t- [Public members](#public-members)\n\t\t- [Rendering](#rendering)\n\t- [Usage tips](#usage-tips)\n\t\t- [Rolling your own](#rolling-your-own)\n\t\t- [Bundling](#bundling)\n\t\t- [Looping](#looping)\n\t\t- [Using htmltree with Transcrypt\u2122](#using-htmltree-with-transcrypt)\n\t- [List of wrapper functions](#list-of-wrapper-functions)\n# Python htmltree project\n\n## Create and manipulate HTML and CSS from the comfort of Python\n * Easy to learn. Consistent, simple syntax.\n * 85 predefined tag functions.\n * Create HTML on the fly or save as static files.\n * Flexible usage and easy extension. \n * Run locally with CPython or as Javascript in the browser using Jacques De Hooge's [*Transcrypt\u2122*](https://transcrypt.org/) Python to JS transpiler\n * Dependencies: Python 3.x\n\n### Installation\n`pip install htmltree`\n\n### Quick Start\n\n#### Open a Python interpreter and type or paste the following\n```\nfrom htmltree import *\nhead = Head()\nbody = Body()\ndoc = Html(head, body)\n```\n#### Render and print the HTML\n```\n>>> print(doc.render(0))\n\n \n \n \n \n\n```\n#### Now add some styling and text\n```\nwho = Meta(name=\"author\",content=\"Your Name Here\")\nhead.C.append(who)\nbody.A.update(dict(style={'background-color':'black'}))\nbanner = H1(\"Hello, htmltree!\", _class='banner', style={'color':'green'})\nbody.C.append(banner)\n```\n#### and print the result.\n```\n>>> print(doc.render(0))\n\n \n \n \n \n

\n Hello, htmltree!\n

\n \n\n```\nIn the examples above, we created elements and assigned them to variables so we could alter their content later. However, we could also have written it out all at once.\n\n```\ndoc = Html(\n Head(\n Meta(name=\"author\",content=\"Your Name Here\")),\n Body(\n H1(\"Hello, htmltree!\", _class='banner', style={'color':'green'}),\n style={'background-color':'black'}))\n```\n\nThat's short and clean and renders exactly the same html. It also mimics the page structure but sacrifices ease of alteration later in the execution. Your choices should come down to whether you're creating static html or dynamic content based on information that's not available until run time.\n\n### Reserved words and hyphenated attributes\nDid you notice the underscore in `H1(\"Hello, htmltree!\", _class='banner', ...)`? It's written that way because `class` is a Python keyword. Trying to use it as an identifier will raise a syntax error. \n\nAs a convenience, all the wrapper functions strip off leading and trailing underscores in attribute names, so `class_` would also work. Normal HTML doesn't use underscores in attribute names so this fix is safe to use. I think `for` as a `