PyJSX #45
metaperl
started this conversation in
Framework Discussion: Specific
PyJSX
#45
Replies: 1 comment
-
https://www.reddit.com/r/Python/comments/1falc1s/pyjsx_write_jsx_directly_in_python/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
PyJSX - Write JSX directly in Python
Installation
Get it via pip:
Minimal example
Tip
There are more examples available in the examples folder.
Each file containing JSX must contain two things:
# coding: jsx
directive - This tells Python to let our library parse thefile first.
from pyjsx import jsx
import. PyJSX transpiles JSX intojsx(...)
calls soit must be in scope.
To run a file containing JSX, the
jsx
codec must be registered first which canbe done with
from pyjsx import auto_setup
. This must occur before importingany other file containing JSX.
Supported grammar
The full JSX grammar is supported.
Here are a few examples:
Normal and self-closing tags
Props
Nested expressions
Fragments
Custom components
A custom component can be any function that takes
**kwargs
andreturns JSX or a plain string. The special prop
children
is a listcontaining the element's children.
Prior art
Inspired by packed and
pyxl4.
Beta Was this translation helpful? Give feedback.
All reactions