Package: pyMarkupL
pyMarkupL(Python Markup Language) Streamline the production of your HTML page using this python framework.Creating an HTML page can be very repetitive,
often having to copy and paste multiple lines
code to modify minimal things, like a
description.pyMarkupL greatly speeds up this process, giving
possibility to create elements with parameters
and / or fully customizable sub-elements.InstallationTo install pyMarkupL, simply run this command in your terminal of choice:> pip install pyMarkupLRight after installation, the commandpmlwill be available, to check if everything was installed correctly open a terminal and do the following command:> pml okIf you do not receive a response it means there was a problem during installation.Starting a projectTo start developing your page, you must first organize your work environment.Enter a directory where you want to store your code, run the following command:> pml initThis command will generate a set of files needed to run your application, to do a brief test, runmanage.pypassing asrunargument:> python manage.py runThis will generate a file inoutput/debugnameddebug.htmlas configured insettings.py.For more information on how to generate your page go to the "Run" topic.Understanding the StructureThis is the structure of the files in the repository.│   settings.py
│    manage.py
│  
└── src
    │   main.py
    │
    └── components
        │   box.py
        │   toolbar.py
        │   text.py
        │
        └──static
            └── style.pyThe way the entire project is structured is at the discretion of the developer, I used this pattern as an example only.settings.pyWhere we configure some aspects of our project.fromsrc.mainimportMainMAIN_ELEMENT=MainMAIN_ELEMENTIs a constant, where we tell our project which is the main element,which in this example isMain.These constants can be changed at any time, again, as stated before:
the way the entire project is structured is at the discretion of the developer.src/All components of that project are found here.└── src
    │   main.py
    │
    └── components
        │   box.py
        │   toolbar.py
        │   text.py
        │
        └──static
            └── style.pysrc/main.pyContains the main element, the one that was called insettings.pyfromcore.elementsimportElementfromsrc.components.static.styleimportMyStylefromsrc.components.toolbarimportToolbarfromsrc.components.boximportBoxclassMain(Element):defrender(self,**kwargs):return'''<MyStyle><Toolbar(title="pyMarkupL")><div class="container"><Box(title="Title 1")><Box(title="Title 2")><Box(title="Title 3")></div>'''See how simple it is to create an element.fromcore.elementsimportElementWe import ofElementwhich is incore.elementsThis is an abstract class, to create an element just inherit it and add/modify some parameters and methods.classMain(Element):...We created a class that inherits fromElement, thus indicating thatMainis an elementWith just these steps we already have an element, however, it does not render anything, if you try to run an element like this you will receive an EmptyCode error.
That's why therendermethod exists.defrender(self,**kwargs)->str:return'''...'''The "render" method is responsible for returning one or more elements, both HTML and pML Elememnts (Classes that inherit fromElement).
This method must return astrand, within that string, can contain HTML elements:<divclass="container">...</div>and pML elements:<Toolbar(title="pyMarkupL")>There is no limit on the number of elements being returned, be careful only with the syntax, because depending on the error nothing will be raised.Don't worry if you can't understand what<Toolbar(title="pyMarkupL")>does, or how it works, right after this topic we'll explain everything right....RunTo test this application use the command:> python manage.py runThis will generate a file inoutput/debugnameddebug.htmlas configured insettings.py.To modify the path of this file change the constantUTPUT_DEBUGinsettings.pyThis documentation is still in production, so give this repository a star, as soon as possible we will finalizeGoalThis framework aims to facilitate the creation of html pages using python code. it will be possible to: create reusable elements that can change its parameters, run a local server to view specific pages and components, thus facilitating testing, among other features.