domConverter.js 854 B

123456789101112131415161718192021222324252627282930313233
  1. // Generated by CoffeeScript 1.12.7
  2. var domToMarkup, object, objectToSaneObject, saneObjectToDom, self;
  3. objectToSaneObject = require('./objectToSaneObject');
  4. saneObjectToDom = require('./saneObjectToDom');
  5. domToMarkup = require('./domToMarkup');
  6. object = require('utila').object;
  7. module.exports = self = {
  8. objectToDom: function(o) {
  9. o = self._object2SaneObject(o);
  10. return saneObjectToDom.convert(o);
  11. },
  12. object2markup: function(o) {
  13. var dom;
  14. dom = self.objectToDom(o);
  15. return domToMarkup.convert(dom);
  16. },
  17. domToMarkup: function(dom) {
  18. return domToMarkup.convert(dom);
  19. },
  20. _object2SaneObject: function(o) {
  21. if (!Array.isArray(o)) {
  22. if (!object.isBareObject(o)) {
  23. throw Error("toDom() only accepts arrays and bare objects as input");
  24. }
  25. }
  26. return objectToSaneObject.sanitize(o);
  27. }
  28. };