Skip to main content

A component parser for html

Project description

#+title: Readme

Compyte is a component library for python which lets you have components in html. It takes in a html with the *Compyte* syntax and returns the html with component results. It has a integrated python run envirionment with the syntax.

load stuff (using python exec to load python to the python envirionment)
#+begin_src django
{$ import os $}
{$ name='Compyte'+' toilet' $}
#+end_src

executing (using eval and replaces with result)
#+begin_src django
{% name %}
{% 10 +10 %}
#+end_src

** Components
Components are added with as html with the compontent='[path-to-component-file]'.
The attributes in the html tag will get added to a props dict and passed to the component file. where it can be accesed

#+begin_src django
{% props['propname'] %}
#+end_src

Check out the example down bellow

*** Example

This is a example of the *Compyte* html

- index.html
#+begin_src html
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Untitled</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.12/dist/full.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>

<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<!-- Place favicon.ico in the root directory -->
</head>
<body>
{$ import os $}
<h1>{% os.getcwd() %}</h1>
<card component="./tests/card.html" >
{$ string = 'what is ' + str(10-2) $}
<h1 class="text-4xl font-bold" >test</h1>
<btn title="click" onclick="alert('{% string %}')" component="./tests/button.html"></btn>
</card>
</body>
</html>

#+end_src

-card.html
#+begin_src html
<div class="bg-base-200 rounded-lg p-12" >
{% props['children'] %}
</div>
#+end_src

-button.html
#+begin_src html
<button onclick="{% props['onclick'] %}" class="btn btn-primary" >
{% props['title'] %}
</button>
#+end_src


-main.py
#+begin_src python
from compyte import *

output = open('tests/output.html','w')
output.write(parse(open("tests/index.html","r").read()))

#+end_src

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

compyter-0.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

Compyter-0.0.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file compyter-0.0.1.tar.gz.

File metadata

  • Download URL: compyter-0.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for compyter-0.0.1.tar.gz
Algorithm Hash digest
SHA256 fbc38c7cc7de4f6d244bd620f1fd733d3dbc5a9ba5cae4c0f04c177bbf1ba5d3
MD5 81b1d8302783d4cef9e6e90d3867a19d
BLAKE2b-256 48394574b16766296de8fb4845f16c249a954c222bee0e6be37aac7b3927c630

See more details on using hashes here.

File details

Details for the file Compyter-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: Compyter-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for Compyter-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 100e7da177a49e86aa6f3d263c7ad1ac73db039cb8881ce6f8ec6d7116e6c2e6
MD5 50f9f0238e9a034b27dbd2042cc43034
BLAKE2b-256 2b09f7b15949ef552490e0aeff80a5c74f2b4127a4121d030ce21dacbf37530c

See more details on using hashes here.

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