Skip to content

Instantly share code, notes, and snippets.

@vito
Created September 21, 2010 02:00
Show Gist options
  • Save vito/589053 to your computer and use it in GitHub Desktop.
Save vito/589053 to your computer and use it in GitHub Desktop.
if: a?
then: { a }
else: {
if: b?
then: { b }
else: { c }
}
condition: {
a? -> a
b? -> b
otherwise -> c
}
condition: (b: Block) :=
if: b contents empty?
then: { raise: "condition: no branches are true" }
else: {
es = b contents
[c, e] = es head targets
check = c evaluate-in: b context
if: check
then: { e evaluate-in: b context }
else: { condition: (Block new: es tail in: b context) }
}
otherwise := True
-- from:
if: h tag empty?
then: { c }
else: {
if: (c empty? && (Self-Closing contains?: h tag))
then: { "<" .. h tag .. attrs .. " />" }
else: {
"<" .. h tag .. attrs .. ">" .. c .. "</" .. h tag .. ">"
}
}
-- to:
condition: {
h tag empty? -> c
c empty? && (Self-Closing contains?: h tag) ->
"<" .. h tag .. attrs .. " />"
otherwise ->
"<" .. h tag .. attrs .. ">" .. c .. "</" .. h tag .. ">"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment