domConverter.coffee 620 B

1234567891011121314151617181920212223242526272829303132
  1. objectToSaneObject = require './objectToSaneObject'
  2. saneObjectToDom = require './saneObjectToDom'
  3. domToMarkup = require './domToMarkup'
  4. {object} = require 'utila'
  5. module.exports = self =
  6. objectToDom: (o) ->
  7. o = self._object2SaneObject o
  8. saneObjectToDom.convert o
  9. object2markup: (o) ->
  10. dom = self.toDom o
  11. domToMarkup.convert dom
  12. domToMarkup: (dom) ->
  13. domToMarkup.convert dom
  14. _object2SaneObject: (o) ->
  15. unless Array.isArray o
  16. unless object.isBareObject o
  17. throw Error "toDom() only accepts arrays and bare objects as input"
  18. objectToSaneObject.sanitize o