Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: af807d7348
Fetching contributors…

Cannot retrieve contributors at this time

66 lines (63 sloc) 3.593 kB
CSS = Origin mimic do(
; namerep is used unquoted inside a doublequoted message to add in names for messages that break under shuffling rules
namerep = method(x, y, x name = y. x)
uncamel = method("To work around the shuffling rules for Messages, uncamel takes a camel cased message name and converts it into a hyphen separated message name",
x, x name = (x name asText replaceAll(#/([A-Z])/, "-$1") lower). x)
comment = method(it, temp = 'internal:createText. temp << "\n/*\n#{it}\n*/\n". temp)
rem = fn(it, temp = 'internal:createText. temp << (it replaceAll(#/(^|(\n))/, "$1//")). temp)
cell(:^) = dsyntax("Convert camelcase name to hyphen split name in place",
[camel]
camel name = (camel name asText replaceAll(#/([A-Z])/, "-$1") lower)
textify = 'internal:createText
textify << camel name asText
if(camel next,
pairen = '(=>)
pairen << camel next
textify -> pairen
)
textify)
makeprop = method("Make an individual css property from a key => value pair, or insert a literal string if one is provided instead", prop, context: CSS,
if(prop value == nil,
" #{prop key}\n",
" #{prop key}: #{prop value};\n")
)
attr = method("Print a selector attribute as part of an attribute list",
k, v,
" #{k}=\"#{v}\"")
render = method(quoted, context: CSS,
first = true
uf = fn(x, ret = unless(first, " ", "") + x. first = false. ret)
quoted flatMap(msg,
case(msg name,
:^, uf(internal:createText(uncamel(msg arguments[0]))),
:internal:createText, uf(internal:createText(msg arguments [0])),
:internal:createNumber, uf(internal:createNumber(msg arguments [0]) asText),
:"{}", first = true
proplist = msg deepCopy
proplist next = nil
proplist = proplist evaluateOn(context, context)
" {\n#{proplist flatMap(prop, makeprop(prop, context: context))}}",
:"", uf("[#{msg arguments flatMap(attr, (attr name) + (internal:createText(attr next arguments[0])))}]"),
:$, uf("." + (msg arguments[0] name)),
:$^, uf("." + internal:createText(uncamel(msg arguments[0]))),
:?, uf("#" + (msg arguments[0] name)),
:?^, uf("#" + internal:createText(uncamel(msg arguments[0]))),
:".", first = true. "\n",
:"|", ", " + render(msg arguments [0]),
else, uf((msg name asText) + if(msg arguments length > 0,
"[#{msg arguments map(arg,
cond(
arg keyword?, (arg name asText)[0...-1]+"="+(arg next asText),
arg name == :"{}", adict = arg evaluateOn(Ground, Ground). adict map(x, attr(x key, x value)) join(", "),
""
)) join(", ")}]",
""))
))
)
fromFile = method("Read a file in CSS render compatible form, and turn it into a Message",
filename,
Message fromText(FileSystem readFully(filename)))
fromQuotedFile = method("Read a file in CSS render compatible quoted form, turn it into a Message, then eval it into the final message",
filename,
Message fromText(FileSystem readFully(filename)) evaluateOn(CSS, CSS))
)
Jump to Line
Something went wrong with that request. Please try again.