GithubHelp home page GithubHelp logo

twidi / mixt Goto Github PK

View Code? Open in Web Editor NEW
42.0 2.0 5.0 970 KB

Write html components directly in python and you have a beautiful but controversial MIXTure

Home Page: https://twidi.github.io/mixt/

License: MIT License

Shell 1.48% Makefile 0.57% Python 97.95%
python html components python36 templating web-components react-style

mixt's People

Contributors

twidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mixt's Issues

Invalid syntax (Python 3.10 issue)

Hello, thanks for this amazing package.
When trying to run this using python 3.10 I first get some errors about collections.Iterator that are easily fixed, but then I got this :

$ python -m mixt.examples.simple
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 157, in _get_module_details
    code = loader.get_code(mod_name)
  File "<frozen importlib._bootstrap_external>", line 1017, in get_code
  File "<frozen importlib._bootstrap_external>", line 947, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/max/projects/mixt/src/mixt/examples/simple.py", line 29
    print(render_example())
SyntaxError: invalid syntax

Support for Django SafeString?

I like to use the Django forms library. But I am not happy with django templates or format_html()

Django has the concept of SafeString so that unsafe data gets escaped, and html does not get escaped twice.

Does mixt support/detect SafeString, so I can create form with the django forms library, and then use the safestring containing the form with mixt?

Not Compatible with Python 3.7

Running mixt-post-install, gives the following stacktrace:

Traceback (most recent call last):
  File "/home/myname/project/venv/bin/mixt-post-install", line 6, in <module>
    from mixt.scripts.mixt_post_install import main
  File "/home/myname/project/venv/lib/python3.7/site-packages/mixt/__init__.py", line 8, in <module>
    from . import exceptions, html as h  # noqa: F401
  File "/home/myname/project/venv/lib/python3.7/site-packages/mixt/html.py", line 24, in <module>
    from .internal.html import (  # noqa: F401  # pylint: disable=unused-import
  File "/home/myname/project/venv/lib/python3.7/site-packages/mixt/internal/html.py", line 7, in <module>
    from .base import (  # noqa: F401  # isort: skip  # pylint: disable=unused-import
  File "/home/myname/project/venv/lib/python3.7/site-packages/mixt/internal/base.py", line 9, in <module>
    from .proptypes import BasePropTypes
  File "/home/myname/project/venv/lib/python3.7/site-packages/mixt/internal/proptypes.py", line 7, in <module>
    import enforce  # we use "enforce" to check complex types
  File "/home/myname/project/venv/lib/python3.7/site-packages/enforce/__init__.py", line 1, in <module>
    from .decorators import runtime_validation
  File "/home/myname/project/venv/lib/python3.7/site-packages/enforce/decorators.py", line 11, in <module>
    from .enforcers import apply_enforcer, Parameters, GenericProxy
  File "/home/myname/project/venv/lib/python3.7/site-packages/enforce/enforcers.py", line 10, in <module>
    from .validator import init_validator, Validator
  File "/home/myname/project/venv/lib/python3.7/site-packages/enforce/validator.py", line 4, in <module>
    from .parsers import get_parser
  File "/home/myname/project/venv/lib/python3.7/site-packages/enforce/parsers.py", line 225, in <module>
    typing.TupleMeta: _parse_tuple,
AttributeError: module 'typing' has no attribute 'TupleMeta'

See:

How to translate to dictionary/list node

It is very interesting project. However, I'd like to translate to a dictionary node than a class object.
How should I look into?
I mean:
<Hello name = "World" />
could translate to
{ 'type':Hello, 'props': { 'name': "World", } }
Why I need this is because it can be lighter than class object.
I can use it for VDOM diff directly.

or translate to a node object.
Node(type=Hello, props = {'name': "World"})

Writing css within components

Thanks for the great package, I much prefer writing components over wrangler templates. I was wondering if there was any interest in allowing the parsing of CSS within the html scope. Ideally, I'd like to write.

from mixt import html, Element, Required

class Hello(Element):
    class PropTypes:
        name: Required[str]

    def render(self, context):
        return (
            <div>
                <style>
                body {
                   background: blue;
                }
                </style>
                <div>Hello, {self.name}</div>
            </div>
        )

That fails with background: blue; SyntaxError: invalid syntax. I figure I could put the css in a string and assign it outside the html scope but that feels a little awkward. Ultimately I'd like to write the css in the component and have it scoped to that component similar to how styled-jsx works, but this would be a nice first step. What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.