Skip to content

MikalROn/MyPy8TML

Repository files navigation

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 between the tag using -> []
  • close tag calling the class -> ()

Using flask to render code

So let's do a form

Remember to download Flask first
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.
  • About

    Just a experiment to make html code in python

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published