git.s-ol.nu mmm / 9436588
add table to mmm/dom convert s-ol 2 years ago
2 changed file(s) with 19 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7070 -- '?index': one level deep
7171 -- '?tree': recursively
7272 index = fileder\get_index facet.name == '?tree'
73 convert 'table', facet.type, index
73 convert 'table', facet.type, index, fileder, facet.name
7474 else
7575 -- fileder and facet given
7676 if not fileder\has_facet facet.name
00 require = relative ..., 1
1 import div, code, img, video, blockquote, a, span, source, iframe from require 'mmm.dom'
1 import div, pre, code, img, video, blockquote, a, span, source, iframe from require 'mmm.dom'
22 import find_fileder, link_to, embed from (require 'mmm.mmmfs.util') require 'mmm.dom'
33 import render from require '.layout'
44 import tohtml from require 'mmm.component'
233233 error "unknown type '#{type obj}'"
234234
235235 (val) => tojson val
236 },
237 {
238 inp: 'table',
239 out: 'mmm/dom',
240 transform: do
241 deep_tostring = (tbl, space='') ->
242 buf = space .. tostring tbl
243
244 return buf unless 'table' == type tbl
245
246 buf = buf .. ' {\n'
247 for k,v in pairs tbl
248 buf = buf .. "#{space} [#{k}]: #{deep_tostring v, space .. ' '}\n"
249 buf = buf .. "#{space}}"
250 buf
251
252 (tbl) => pre code deep_tostring tbl
236253 }
237254 }
238255