Skip to main content

A new way to generates html code using class methods in python

Project description

MyPy8TML

A new way to create a html code inside python

Status of project: in progress...

GitHub

Download

$pip install mypy8tml

Easy start

Generating a simple code:

from mypy_8tml import MyPy8TML

html = MyPy8TML()
html.h1['Hello world']()
code = html.generate()
print(code)
  • Use MyPy8TML( ) to start the class
  • Call the property (name of tag)
  • Put content betwen the tag using -> []
  • close tag calling the class -> ()

Using flask to render code

So let's do a form

Remember to download Flask firt
pip install flask

Pyhton code:

from flask import Flask, render_template_string
from mypy_8tml import MyPy8TML

app = Flask(__name__)

register = MyPy8TML().init_html('Form', 'pt')

register.div.in_class('flex-box')\
        .form.in_class('form')\
            .h1[' Just a simple form']()\
            .p['e-mail :'](-1).input.in_type('email')()\
            .p['password :'](-1).input.in_type('password')()\
            .button.in_type('submit')['submit']()


@app.route('/')
def index():
    return render_template_string(register.generate())

app.run(debug=True)
  • init_html creates a basic html structure
  • Call suports int values, and this values means, a number of times that tags will be closed
  • in_ prefix values puts contents inside tags like class, type, id and etc.
  • Project details


    Download files

    Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

    Source Distribution

    mypy8tml-0.1.1.tar.gz (10.1 kB view hashes)

    Uploaded Source

    Supported by

    AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page