aboutsummaryrefslogtreecommitdiffstats
path: root/lib/dom.server.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-01 10:17:55 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-01 10:17:55 +0000
commit30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b (patch)
treedc56f20ec4d78115e15761c402589b5aec94ef55 /lib/dom.server.moon
parentdefer all scripts (diff)
downloadmmm-30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b.tar.gz
mmm-30fb0dc40d595b9e0b7747ad8e5c4e8cf7e3023b.zip
move mmm code from lib to mmm etc
Diffstat (limited to 'lib/dom.server.moon')
-rw-r--r--lib/dom.server.moon40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/dom.server.moon b/lib/dom.server.moon
deleted file mode 100644
index fe6b60c..0000000
--- a/lib/dom.server.moon
+++ /dev/null
@@ -1,40 +0,0 @@
-import opairs from require 'lib.ordered'
-
-void_tags = { 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr' }
-void_tags = { t,t for t in *void_tags }
-
-element = (element) -> (...) ->
- children = { ... }
-
- -- attributes are last arguments but mustn't be a ReactiveVar
- attributes = children[#children]
- if 'table' == (type attributes) and not attributes.node
- table.remove children
- else
- attributes = {}
-
- b = "<#{element}"
- for k,v in opairs attributes
- if k == 'style' and 'table' == type v
- tmp = ''
- for kk, vv in opairs v
- tmp ..= "#{kk}: #{vv}; "
- v = tmp
- b ..= " #{k}=\"#{v}\""
-
- -- if there is only one argument,
- -- children can be in attributes table too
- if #children == 0
- children = attributes
-
- if void_tags[element]
- assert #children == 0, "void tag #{element} cannot have children!"
- b .. ">"
- else
- b ..= ">" .. table.concat children, ''
- b ..= "</#{element}>"
- b
-
-setmetatable {}, __index: (name) =>
- with val = element name
- @[name] = val