Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Handle loading class in browser

  • Loading branch information...
commit 6449a7c8c2a63cf5ca72a8362267aa03bb1e674b 1 parent 4b0db03
Joel Van Horn authored
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/ObjectTemplate.coffee
17 lib/ObjectTemplate.coffee
View
@@ -1,6 +1,10 @@
-sysmo = require 'sysmo'
-TemplateConfig = require './TemplateConfig'
+# handle CommonJS/Node.js or browser
+
+sysmo ||= (require?) ? require('sysmo') : window.Sysmo
+TemplateConfig ||= (require?) ? require('./TemplateConfig') : window.json2json.TemplateConfig
+
+# class definition
class ObjectTemplate
constructor: (config, parent) ->
@@ -163,5 +167,10 @@ class ObjectTemplate
paths.push(path) if path and paths.indexOf(path) == -1
paths
-# register module
-module.exports = ObjectTemplate
+# register module (CommonJS/Node.js) or handle browser
+
+if module?
+ module.exports = ObjectTemplate
+else
+ window.json2json or= {}
+ window.json2json.ObjectTemplate = ObjectTemplate
Please sign in to comment.
Something went wrong with that request. Please try again.