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 f944a4132e3764139382d47a4c2b257613bc5cae 1 parent 6449a7c
@joelvh authored
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/TemplateConfig.coffee
View
16 lib/TemplateConfig.coffee
@@ -1,5 +1,8 @@
+# handle CommonJS/Node.js or browser
-sysmo = require 'sysmo'
+sysmo ||= (require?) ? require('sysmo') : window.Sysmo
+
+# class definition
class TemplateConfig
constructor: (config) ->
@@ -84,6 +87,11 @@ class TemplateConfig
pair.key = key if 'key' not of pair
pair.value = value if 'value' not of pair
pair
-
-# register module
-module.exports = TemplateConfig
+
+# register module (CommonJS/Node.js) or handle browser
+
+if module?
+ module.exports = TemplateConfig
+else
+ window.json2json or= {}
+ window.json2json.TemplateConfig = TemplateConfig
Please sign in to comment.
Something went wrong with that request. Please try again.