mirror of
https://github.com/urbit/shrub.git
synced 2024-12-12 10:29:01 +03:00
75 lines
2.6 KiB
Plaintext
75 lines
2.6 KiB
Plaintext
|
::
|
||
|
:::: /hoon/elem-to-react-json/lib
|
||
|
::
|
||
|
/? 310
|
||
|
|%
|
||
|
++ react-attrs
|
||
|
~+ ^- (map term cord)
|
||
|
%- molt ^- (list (pair term cord))
|
||
|
:- [%class 'className']
|
||
|
=- (rash - (more next (cook |=(a/tape [(cass a) (crip a)]) (star alf))))
|
||
|
'''
|
||
|
accept acceptCharset accessKey action allowFullScreen allowTransparency alt
|
||
|
async autoComplete autoFocus autoPlay cellPadding cellSpacing charSet checked
|
||
|
classID className colSpan cols content contentEditable contextMenu controls
|
||
|
coords crossOrigin data dateTime defer dir disabled download draggable encType
|
||
|
form formAction formEncType formMethod formNoValidate formTarget frameBorder
|
||
|
headers height hidden high href hrefLang htmlFor httpEquiv icon id label lang
|
||
|
list loop low manifest marginHeight marginWidth max maxLength media mediaGroup
|
||
|
method min multiple muted name noValidate open optimum pattern placeholder
|
||
|
poster preload radioGroup readOnly rel required role rowSpan rows sandbox
|
||
|
scope scoped scrolling seamless selected shape size sizes span spellCheck
|
||
|
src srcDoc srcSet start step style tabIndex target title type useMap value
|
||
|
width wmode
|
||
|
'''
|
||
|
::
|
||
|
++ urb-codemirror :: reactify <pre urb:codemirror>foo</pre>
|
||
|
|= src/manx ^- manx
|
||
|
?> ?=({{$pre *} _;/(**) $~} src)
|
||
|
;codemirror(value "{v.i.a.g.i.c.src}");
|
||
|
::
|
||
|
++ urb-exec :: reactify <pre urb:exec>foo</pre>
|
||
|
|= src/manx
|
||
|
?> ?=({{$pre *} _;/(**) $~} src) :: verify its only a text node
|
||
|
=* code v.i.a.g.i.c.src
|
||
|
=+ =< result=(mule .)
|
||
|
!.(|.((slap !>(.) (ream (crip code))))) :: compile and run safely
|
||
|
=+ claz=?-(-.result $& "rancode", $| "failedcode")
|
||
|
;div(class "{claz}")
|
||
|
;pre:"{code}"
|
||
|
;+ ?- -.result
|
||
|
$& ;code:"{~(ram re (sell p.result))}"
|
||
|
$| ;pre
|
||
|
;div:"error"
|
||
|
;* %+ turn p.result
|
||
|
|= a/tank
|
||
|
^- manx
|
||
|
;div:"{~(ram re a)}"
|
||
|
== == ==
|
||
|
::
|
||
|
++ elem-to-react-json
|
||
|
|= src/manx ^- json
|
||
|
?: ?=(_;/(**) src)
|
||
|
(jape v.i.a.g.src)
|
||
|
=+ atr=(molt `(list (pair mane tape))`a.g.src)
|
||
|
?: (~(has by atr) [%urb %codemirror])
|
||
|
$(src (urb-codemirror src))
|
||
|
?: (~(has by atr) [%urb %exec]) :: runnable code attribute tag
|
||
|
$(src (urb-exec src))
|
||
|
%- jobe :~
|
||
|
c+a+(turn c.src ..$)
|
||
|
gn+s+(mane-to-cord n.g.src)
|
||
|
=< ga+(jobe (turn a.g.src .))
|
||
|
|= {a/mane b/tape} ^- {cord json}
|
||
|
:_ (jape b)
|
||
|
?^ a (mane-to-cord a)
|
||
|
(fall (~(get by react-attrs) a) a)
|
||
|
==
|
||
|
::
|
||
|
++ mane-to-cord |=(a/mane `cord`?@(a a (rap 3 -.a ':' +.a ~)))
|
||
|
--
|
||
|
::
|
||
|
::::
|
||
|
::
|
||
|
elem-to-react-json
|