-
-
Notifications
You must be signed in to change notification settings - Fork 216
Description
In creating a Transcrypt-based React app (see my other question), I needed to write JSX into my code. JSX is a transpiled language, just like Transcrypt. I made it work by using strings:
elem = self.jsx('''
<div id="StudentContainer">
{self.props.students.map((s) => (
<StudentTile student={s} key={s.searchval} />
))}
</div>
''')
Not the best way because the JSX is converted at runtime on the browser.
I'm wondering how hard it would be to have a __pragma__
that takes some portion of code and "shells" out to a separate program for processing, piping the content over. Then Transcrypt emits the return. That would allow me to put JSX between two pragmas and get it converted to JS by some outside engine.
The code could then be something like this:
elem = \
__pragma__('ext_on', 'jsx_transform_executable --o1 --o2')
<div id="StudentContainer">
{self.props.students.map((s) => (
<StudentTile student={s} key={s.searchval} />
))}
</div>
__pragma__('ext_off')
This type of command would be useful to much more than JSX. Any kind of pre or post transformations of parts of code could be triggered by the transcrypt engine.