Permalink
Browse files

Handlebars template is now precompiled in the build process.

  • Loading branch information...
1 parent 96d726d commit 4fd21adbbfe88a3685ea731901eb1e7933eec41c @zeke zeke committed Apr 12, 2012
Showing with 41,222 additions and 2,540 deletions.
  1. +42 −60 Cakefile
  2. +223 −0 lib/grounds/handlebars.runtime-1.0.0.beta.6.js
  3. +34 −0 lib/grounds/swagger-ui.js
  4. +302 −0 lib/grounds/swagger.js
  5. +110 −0 lib/grounds/template.js
  6. +2 −2 lib/swagger-ui-spec.js
  7. +368 −260 lib/swagger-ui.js
  8. +1 −0 node_modules/.bin/handlebars
  9. +11 −0 node_modules/handlebars/.npmignore
  10. +20 −0 node_modules/handlebars/LICENSE
  11. +315 −0 node_modules/handlebars/README.markdown
  12. +139 −0 node_modules/handlebars/bin/handlebars
  13. +14 −0 node_modules/handlebars/lib/handlebars.js
  14. +99 −0 node_modules/handlebars/lib/handlebars/base.js
  15. +103 −0 node_modules/handlebars/lib/handlebars/compiler/ast.js
  16. +27 −0 node_modules/handlebars/lib/handlebars/compiler/base.js
  17. +805 −0 node_modules/handlebars/lib/handlebars/compiler/compiler.js
  18. +7 −0 node_modules/handlebars/lib/handlebars/compiler/index.js
  19. +480 −0 node_modules/handlebars/lib/handlebars/compiler/parser.js
  20. +137 −0 node_modules/handlebars/lib/handlebars/compiler/printer.js
  21. +13 −0 node_modules/handlebars/lib/handlebars/compiler/visitor.js
  22. +68 −0 node_modules/handlebars/lib/handlebars/runtime.js
  23. +68 −0 node_modules/handlebars/lib/handlebars/utils.js
  24. +1 −0 node_modules/handlebars/node_modules/.bin/uglifyjs
  25. +4 −0 node_modules/handlebars/node_modules/optimist/.npmignore
  26. +21 −0 node_modules/handlebars/node_modules/optimist/LICENSE
  27. +485 −0 node_modules/handlebars/node_modules/optimist/README.markdown
  28. +10 −0 node_modules/handlebars/node_modules/optimist/examples/bool.js
  29. +7 −0 node_modules/handlebars/node_modules/optimist/examples/boolean_double.js
  30. +7 −0 node_modules/handlebars/node_modules/optimist/examples/boolean_single.js
  31. +8 −0 node_modules/handlebars/node_modules/optimist/examples/default_hash.js
  32. +7 −0 node_modules/handlebars/node_modules/optimist/examples/default_singles.js
  33. +8 −0 node_modules/handlebars/node_modules/optimist/examples/divide.js
  34. +20 −0 node_modules/handlebars/node_modules/optimist/examples/line_count.js
  35. +29 −0 node_modules/handlebars/node_modules/optimist/examples/line_count_options.js
  36. +29 −0 node_modules/handlebars/node_modules/optimist/examples/line_count_wrap.js
  37. +4 −0 node_modules/handlebars/node_modules/optimist/examples/nonopt.js
  38. +2 −0 node_modules/handlebars/node_modules/optimist/examples/reflect.js
  39. +3 −0 node_modules/handlebars/node_modules/optimist/examples/short.js
  40. +11 −0 node_modules/handlebars/node_modules/optimist/examples/string.js
  41. +19 −0 node_modules/handlebars/node_modules/optimist/examples/usage-options.js
  42. +10 −0 node_modules/handlebars/node_modules/optimist/examples/xup.js
  43. +470 −0 node_modules/handlebars/node_modules/optimist/index.js
  44. +1 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/.npmignore
  45. +70 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/README.markdown
  46. +10 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/center.js
  47. +3 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/meat.js
  48. +76 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/index.js
  49. +37 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/package.json
  50. +30 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/break.js
  51. +63 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/idleness.txt
  52. +31 −0 node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/wrap.js
  53. +43 −0 node_modules/handlebars/node_modules/optimist/package.json
  54. +66 −0 node_modules/handlebars/node_modules/optimist/test/_.js
  55. +2 −0 node_modules/handlebars/node_modules/optimist/test/_/argv.js
  56. +3 −0 node_modules/handlebars/node_modules/optimist/test/_/bin.js
  57. +322 −0 node_modules/handlebars/node_modules/optimist/test/parse.js
  58. +256 −0 node_modules/handlebars/node_modules/optimist/test/usage.js
  59. +4 −0 node_modules/handlebars/node_modules/uglify-js/.npmignore
  60. +981 −0 node_modules/handlebars/node_modules/uglify-js/README.html
  61. +578 −0 node_modules/handlebars/node_modules/uglify-js/README.org
  62. +332 −0 node_modules/handlebars/node_modules/uglify-js/bin/uglifyjs
  63. +75 −0 node_modules/handlebars/node_modules/uglify-js/docstyle.css
  64. +2,599 −0 node_modules/handlebars/node_modules/uglify-js/lib/consolidator.js
  65. +75 −0 node_modules/handlebars/node_modules/uglify-js/lib/object-ast.js
  66. +1,346 −0 node_modules/handlebars/node_modules/uglify-js/lib/parse-js.js
  67. +2,011 −0 node_modules/handlebars/node_modules/uglify-js/lib/process.js
  68. +73 −0 node_modules/handlebars/node_modules/uglify-js/lib/squeeze-more.js
  69. +24 −0 node_modules/handlebars/node_modules/uglify-js/package.json
  70. +24 −0 node_modules/handlebars/node_modules/uglify-js/package.json~
  71. +28 −0 node_modules/handlebars/node_modules/uglify-js/test/beautify.js
  72. +403 −0 node_modules/handlebars/node_modules/uglify-js/test/testparser.js
  73. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array1.js
  74. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array2.js
  75. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array3.js
  76. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array4.js
  77. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/assignment.js
  78. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/concatstring.js
  79. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/const.js
  80. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/empty-blocks.js
  81. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/forstatement.js
  82. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/if.js
  83. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/ifreturn.js
  84. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/ifreturn2.js
  85. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue10.js
  86. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue11.js
  87. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue13.js
  88. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue14.js
  89. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue16.js
  90. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue17.js
  91. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue20.js
  92. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue21.js
  93. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue25.js
  94. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue27.js
  95. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue278.js
  96. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue28.js
  97. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue29.js
  98. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue30.js
  99. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue34.js
  100. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue4.js
  101. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue48.js
  102. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue50.js
  103. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue53.js
  104. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue54.1.js
  105. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue68.js
  106. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue69.js
  107. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/issue9.js
  108. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/mangle.js
  109. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/null_string.js
  110. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/strict-equals.js
  111. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/var.js
  112. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/whitespace.js
  113. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/with.js
  114. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/array1.js
  115. +4 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/array2.js
  116. +4 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/array3.js
  117. +6 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/array4.js
  118. +20 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/assignment.js
  119. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/concatstring.js
  120. +5 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/const.js
  121. +4 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/empty-blocks.js
  122. +10 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/forstatement.js
  123. +6 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/if.js
  124. +9 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/ifreturn.js
  125. +16 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/ifreturn2.js
  126. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue10.js
  127. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue11.js
  128. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue13.js
  129. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue14.js
  130. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue16.js
  131. +4 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue17.js
  132. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue20.js
  133. +6 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue21.js
  134. +7 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue25.js
  135. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue27.js
  136. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue278.js
  137. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue28.js
  138. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue29.js
  139. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue30.js
  140. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue34.js
  141. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue4.js
  142. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue48.js
  143. +9 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue50.js
  144. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue53.js
  145. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue54.1.js
  146. +5 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue68.js
  147. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue69.js
  148. +4 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/issue9.js
  149. +5 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/mangle.js
  150. +1 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/null_string.js
  151. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/strict-equals.js
  152. +3 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/var.js
  153. +21 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/whitespace.js
  154. +2 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/compress/test/with.js
  155. +55 −0 node_modules/handlebars/node_modules/uglify-js/test/unit/scripts.js
  156. +13 −0 node_modules/handlebars/node_modules/uglify-js/tmp/269.js
  157. +22,315 −0 node_modules/handlebars/node_modules/uglify-js/tmp/app.js
  158. +15 −0 node_modules/handlebars/node_modules/uglify-js/tmp/embed-tokens.js
  159. +26 −0 node_modules/handlebars/node_modules/uglify-js/tmp/goto.js
  160. +8 −0 node_modules/handlebars/node_modules/uglify-js/tmp/goto2.js
  161. +33 −0 node_modules/handlebars/node_modules/uglify-js/tmp/hoist.js
  162. +97 −0 node_modules/handlebars/node_modules/uglify-js/tmp/instrument.js
  163. +138 −0 node_modules/handlebars/node_modules/uglify-js/tmp/instrument2.js
  164. +8 −0 node_modules/handlebars/node_modules/uglify-js/tmp/liftvars.js
  165. +30 −0 node_modules/handlebars/node_modules/uglify-js/tmp/test.js
  166. +3,930 −0 node_modules/handlebars/node_modules/uglify-js/tmp/uglify-hangs.js
  167. +166 −0 node_modules/handlebars/node_modules/uglify-js/tmp/uglify-hangs2.js
  168. +18 −0 node_modules/handlebars/node_modules/uglify-js/uglify-js.js
  169. +25 −0 node_modules/handlebars/package.json
  170. +2 −2 src/swagger-ui-spec.coffee
  171. +1 −1 src/swagger-ui.coffee
  172. +3 −3 src/template.html
  173. +0 −1,801 src/vendor/handlebars.coffee
  174. +0 −186 src/vendor/handlebars.runtime.coffee
  175. +0 −225 src/vendor/swagger.coffee
View
102 Cakefile
@@ -1,9 +1,14 @@
-fs = require 'fs'
-{exec} = require 'child_process'
-util = require 'util'
-request = require 'request'
+fs = require 'fs'
+{exec} = require 'child_process'
+util = require 'util'
+request = require 'request'
+handlebars = require 'handlebars'
+
+task 'spec', "Run the test suite", ->
+ exec "open spec.html", (err, stdout, stderr) ->
+ throw err if err
-task 'watch', 'Watch all source files for changes and autocompile', ->
+task 'watch', 'Watch source files for changes and autocompile', ->
notify "Watching source files for changes..."
fs.watchFile "src/swagger-ui.coffee", (curr, prev) ->
@@ -12,65 +17,42 @@ task 'watch', 'Watch all source files for changes and autocompile', ->
fs.watchFile "src/swagger-ui-spec.coffee", (curr, prev) ->
if +curr.mtime isnt +prev.mtime
- invoke 'bakeSpec'
+ invoke 'bake_spec'
+
+task 'bake', 'Compile everything into swagger-ui.js', ->
+ # Transpile the spec
+ invoke 'bake_spec'
-task 'updateSwagger', 'Download the lastest version of swagger.coffee from Github', ->
- request "https://raw.github.com/wordnik/swagger.js/master/src/swagger.coffee", (err, response, body) ->
- fs.writeFile "src/vendor/swagger.coffee", body, 'utf8', (err) ->
+ # Transpile swagger-ui.coffee
+ exec "coffee --compile --output lib/grounds/ src/swagger-ui.coffee", (err, stdout, stderr) ->
+ throw err if err
+
+ # Precompile the Handlebars template
+ exec "handlebars src/template.html -f lib/grounds/template.js", (err, stdout, stderr) ->
throw err if err
- notify "Downloaded the latest swagger.coffee from Github"
+
+ # Join all the js files into one
+ exec "cat lib/grounds/*.js > lib/swagger-ui.js", (err, stdout, stderr) ->
+ throw err if err
+
+ notify 'lib/swagger-ui.js is ready'
-task 'bakeSpec', 'Compile swagger-ui-spec.coffee to swagger-ui-spec.js', ->
+# This is separate from the regular bake task for faster compilation during development
+task 'bake_spec', 'Compile spec from coffee to js', ->
exec "coffee --compile --output lib/ src/swagger-ui-spec.coffee ", (err, stdout, stderr) ->
throw err if err
notify 'compiled lib/swagger-ui-spec.js'
-
-task 'bake', 'Group coffee files and compile to swagger-ui.js', ->
-
- # Compile the spec
- invoke 'bakeSpec'
-
- beans = new Array
-
- # Add swagger.coffee
- fs.readFile "src/vendor/swagger.coffee", 'utf8', (err, swagger) ->
- throw err if err
- beans.push swagger
-
- # Add handlebars (runtime)
- fs.readFile "src/vendor/handlebars.runtime.coffee", 'utf8', (err, handlebars) ->
+
+task 'buy_ingredients', 'Download dependencies from Github', ->
+ request "https://raw.github.com/wordnik/swagger.js/master/lib/swagger.js", (err, response, body) ->
+ fs.writeFile "lib/grounds/swagger.js", body, 'utf8', (err) ->
throw err if err
- beans.push handlebars
-
- # Read the HTML template file
- fs.readFile "src/template.html", 'utf8', (err, templateContent) ->
- throw err if err
-
- # Store the template in a global variable.
- beans.push "window.swagger_template = \"#{templateContent}\""
-
- # Read swagger-ui.coffee
- fs.readFile "src/swagger-ui.coffee", 'utf8', (err, content) ->
- throw err if err
- beans.push content
-
- # Join coffee beans into a temporary coffee file
- fs.writeFile "swagger-ui.coffee", beans.join('\n\n'), 'utf8', (err) ->
- throw err if err
-
- # Compile to Javascript
- exec "coffee --compile --output lib/ swagger-ui.coffee ", (err, stdout, stderr) ->
- throw err if err
-
- # Remove the temporary coffee file
- fs.unlink "swagger-ui.coffee", (err) ->
- throw err if err
- notify 'compiled lib/swagger-ui.js'
-
-notify = (message = '') ->
- options = {
- title: 'CoffeeScript'
- image: 'lib/CoffeeScript.png'
- }
- console.log message
- try require('growl') message, options
+ notify "Downloaded the latest swagger.js from Github"
+
+notify = (message) ->
+ return unless message?
+ options =
+ title: 'CoffeeScript'
+ image: 'lib/CoffeeScript.png'
+ console.log message
+ try require('growl') message, options
View
223 lib/grounds/handlebars.runtime-1.0.0.beta.6.js
@@ -0,0 +1,223 @@
+// lib/handlebars/base.js
+var Handlebars = {};
+
+Handlebars.VERSION = "1.0.beta.6";
+
+Handlebars.helpers = {};
+Handlebars.partials = {};
+
+Handlebars.registerHelper = function(name, fn, inverse) {
+ if(inverse) { fn.not = inverse; }
+ this.helpers[name] = fn;
+};
+
+Handlebars.registerPartial = function(name, str) {
+ this.partials[name] = str;
+};
+
+Handlebars.registerHelper('helperMissing', function(arg) {
+ if(arguments.length === 2) {
+ return undefined;
+ } else {
+ throw new Error("Could not find property '" + arg + "'");
+ }
+});
+
+var toString = Object.prototype.toString, functionType = "[object Function]";
+
+Handlebars.registerHelper('blockHelperMissing', function(context, options) {
+ var inverse = options.inverse || function() {}, fn = options.fn;
+
+
+ var ret = "";
+ var type = toString.call(context);
+
+ if(type === functionType) { context = context.call(this); }
+
+ if(context === true) {
+ return fn(this);
+ } else if(context === false || context == null) {
+ return inverse(this);
+ } else if(type === "[object Array]") {
+ if(context.length > 0) {
+ for(var i=0, j=context.length; i<j; i++) {
+ ret = ret + fn(context[i]);
+ }
+ } else {
+ ret = inverse(this);
+ }
+ return ret;
+ } else {
+ return fn(context);
+ }
+});
+
+Handlebars.registerHelper('each', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ var ret = "";
+
+ if(context && context.length > 0) {
+ for(var i=0, j=context.length; i<j; i++) {
+ ret = ret + fn(context[i]);
+ }
+ } else {
+ ret = inverse(this);
+ }
+ return ret;
+});
+
+Handlebars.registerHelper('if', function(context, options) {
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if(!context || Handlebars.Utils.isEmpty(context)) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+});
+
+Handlebars.registerHelper('unless', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ options.fn = inverse;
+ options.inverse = fn;
+
+ return Handlebars.helpers['if'].call(this, context, options);
+});
+
+Handlebars.registerHelper('with', function(context, options) {
+ return options.fn(context);
+});
+
+Handlebars.registerHelper('log', function(context) {
+ Handlebars.log(context);
+});
+;
+// lib/handlebars/utils.js
+Handlebars.Exception = function(message) {
+ var tmp = Error.prototype.constructor.apply(this, arguments);
+
+ for (var p in tmp) {
+ if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
+ }
+
+ this.message = tmp.message;
+};
+Handlebars.Exception.prototype = new Error;
+
+// Build out our basic SafeString type
+Handlebars.SafeString = function(string) {
+ this.string = string;
+};
+Handlebars.SafeString.prototype.toString = function() {
+ return this.string.toString();
+};
+
+(function() {
+ var escape = {
+ "<": "&lt;",
+ ">": "&gt;",
+ '"': "&quot;",
+ "'": "&#x27;",
+ "`": "&#x60;"
+ };
+
+ var badChars = /&(?!\w+;)|[<>"'`]/g;
+ var possible = /[&<>"'`]/;
+
+ var escapeChar = function(chr) {
+ return escape[chr] || "&amp;";
+ };
+
+ Handlebars.Utils = {
+ escapeExpression: function(string) {
+ // don't escape SafeStrings, since they're already safe
+ if (string instanceof Handlebars.SafeString) {
+ return string.toString();
+ } else if (string == null || string === false) {
+ return "";
+ }
+
+ if(!possible.test(string)) { return string; }
+ return string.replace(badChars, escapeChar);
+ },
+
+ isEmpty: function(value) {
+ if (typeof value === "undefined") {
+ return true;
+ } else if (value === null) {
+ return true;
+ } else if (value === false) {
+ return true;
+ } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
+})();;
+// lib/handlebars/runtime.js
+Handlebars.VM = {
+ template: function(templateSpec) {
+ // Just add water
+ var container = {
+ escapeExpression: Handlebars.Utils.escapeExpression,
+ invokePartial: Handlebars.VM.invokePartial,
+ programs: [],
+ program: function(i, fn, data) {
+ var programWrapper = this.programs[i];
+ if(data) {
+ return Handlebars.VM.program(fn, data);
+ } else if(programWrapper) {
+ return programWrapper;
+ } else {
+ programWrapper = this.programs[i] = Handlebars.VM.program(fn);
+ return programWrapper;
+ }
+ },
+ programWithDepth: Handlebars.VM.programWithDepth,
+ noop: Handlebars.VM.noop
+ };
+
+ return function(context, options) {
+ options = options || {};
+ return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+ };
+ },
+
+ programWithDepth: function(fn, data, $depth) {
+ var args = Array.prototype.slice.call(arguments, 2);
+
+ return function(context, options) {
+ options = options || {};
+
+ return fn.apply(this, [context, options.data || data].concat(args));
+ };
+ },
+ program: function(fn, data) {
+ return function(context, options) {
+ options = options || {};
+
+ return fn(context, options.data || data);
+ };
+ },
+ noop: function() { return ""; },
+ invokePartial: function(partial, name, context, helpers, partials, data) {
+ options = { helpers: helpers, partials: partials, data: data };
+
+ if(partial === undefined) {
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
+ } else if(partial instanceof Function) {
+ return partial(context, options);
+ } else if (!Handlebars.compile) {
+ throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
+ } else {
+ partials[name] = Handlebars.compile(partial);
+ return partials[name](context, options);
+ }
+ }
+};
+
+Handlebars.template = Handlebars.VM.template;
+;
View
34 lib/grounds/swagger-ui.js
@@ -0,0 +1,34 @@
+(function() {
+ var SwaggerUi,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
+ SwaggerUi = (function() {
+
+ SwaggerUi.prototype.dom_id = "swagger_ui";
+
+ function SwaggerUi(options) {
+ if (options == null) options = {};
+ this.render = __bind(this.render, this);
+ if (options.dom_id != null) {
+ this.dom_id = options.dom_id;
+ delete options.dom_id;
+ }
+ options.success = this.render;
+ this.api = new SwaggerApi(options);
+ }
+
+ SwaggerUi.prototype.render = function() {
+ if (!($("#" + this.dom_id).length > 0)) {
+ $('body').append("<div id='" + this.dom_id + "'></div>");
+ }
+ this.ready = true;
+ return this;
+ };
+
+ return SwaggerUi;
+
+ })();
+
+ window.SwaggerUi = SwaggerUi;
+
+}).call(this);
View
302 lib/grounds/swagger.js
@@ -0,0 +1,302 @@
+(function() {
+ var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
+ SwaggerApi = (function() {
+
+ SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
+
+ SwaggerApi.prototype.debug = false;
+
+ SwaggerApi.prototype.api_key = null;
+
+ SwaggerApi.prototype.basePath = null;
+
+ function SwaggerApi(options) {
+ if (options == null) options = {};
+ if (options.discoveryUrl != null) this.discoveryUrl = options.discoveryUrl;
+ if (options.debug != null) this.debug = options.debug;
+ if (options.apiKey != null) this.api_key = options.apiKey;
+ if (options.api_key != null) this.api_key = options.api_key;
+ if (options.verbose != null) this.verbose = options.verbose;
+ if (options.success != null) this.success = options.success;
+ if (options.success != null) this.build();
+ }
+
+ SwaggerApi.prototype.build = function() {
+ var _this = this;
+ return $.getJSON(this.discoveryUrl, function(response) {
+ var res, resource, _i, _len, _ref;
+ _this.basePath = response.basePath;
+ if (_this.basePath.match(/^HTTP/i) == null) {
+ throw "discoveryUrl basePath must be a URL.";
+ }
+ _this.basePath = _this.basePath.replace(/\/$/, '');
+ _this.resources = {};
+ _ref = response.apis;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ resource = _ref[_i];
+ if (resource.path === "/tracking.{format}" || resource.path === "/partner.{format}") {
+ continue;
+ }
+ res = new SwaggerResource(resource.path, resource.description, _this);
+ _this.resources[res.name] = res;
+ }
+ return _this;
+ });
+ };
+
+ SwaggerApi.prototype.selfReflect = function() {
+ var resource, resource_name, _ref;
+ if (this.resources == null) return false;
+ _ref = this.resources;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ if (resource.ready == null) return false;
+ }
+ this.ready = true;
+ if (this.success != null) return this.success();
+ };
+
+ SwaggerApi.prototype.help = function() {
+ var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref2, _ref3;
+ _ref = this.resources;
+ for (resource_name in _ref) {
+ resource = _ref[resource_name];
+ console.log(resource_name);
+ _ref2 = resource.operations;
+ for (operation_name in _ref2) {
+ operation = _ref2[operation_name];
+ console.log(" " + operation.nickname);
+ _ref3 = operation.parameters;
+ for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
+ parameter = _ref3[_i];
+ console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ }
+ }
+ return this;
+ };
+
+ return SwaggerApi;
+
+ })();
+
+ SwaggerResource = (function() {
+
+ function SwaggerResource(path, description, api) {
+ var parts,
+ _this = this;
+ this.path = path;
+ this.description = description;
+ this.api = api;
+ if (this.path == null) throw "SwaggerResources must have a path.";
+ this.operations = {};
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
+ parts = this.path.split("/");
+ this.name = parts[parts.length - 1].replace('.{format}', '');
+ $.getJSON(this.url, function(response) {
+ var endpoint, o, op, _i, _j, _len, _len2, _ref, _ref2;
+ _this.basePath = response.basePath;
+ _this.basePath = _this.basePath.replace(/\/$/, '');
+ if (response.apis) {
+ _ref = response.apis;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ endpoint = _ref[_i];
+ if (endpoint.operations) {
+ _ref2 = endpoint.operations;
+ for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
+ o = _ref2[_j];
+ op = new SwaggerOperation(o.nickname, endpoint.path, o.httpMethod, o.parameters, o.summary, _this);
+ _this.operations[op.nickname] = op;
+ }
+ }
+ }
+ }
+ _this.api[_this.name] = _this;
+ _this.ready = true;
+ return _this.api.selfReflect();
+ });
+ }
+
+ SwaggerResource.prototype.help = function() {
+ var operation, operation_name, parameter, _i, _len, _ref, _ref2;
+ _ref = this.operations;
+ for (operation_name in _ref) {
+ operation = _ref[operation_name];
+ console.log(" " + operation.nickname);
+ _ref2 = operation.parameters;
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
+ parameter = _ref2[_i];
+ console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ }
+ return this;
+ };
+
+ return SwaggerResource;
+
+ })();
+
+ SwaggerOperation = (function() {
+
+ function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
+ var _this = this;
+ this.nickname = nickname;
+ this.path = path;
+ this.httpMethod = httpMethod;
+ this.parameters = parameters != null ? parameters : [];
+ this.summary = summary;
+ this.resource = resource;
+ this["do"] = __bind(this["do"], this);
+ if (this.nickname == null) throw "SwaggerOperations must have a nickname.";
+ if (this.path == null) {
+ throw "SwaggerOperation " + nickname + " is missing path.";
+ }
+ if (this.httpMethod == null) {
+ throw "SwaggerOperation " + nickname + " is missing httpMethod.";
+ }
+ this.path = this.path.replace('{format}', 'json');
+ this.resource[this.nickname] = function(args, callback, error) {
+ return _this["do"](args, callback, error);
+ };
+ }
+
+ SwaggerOperation.prototype["do"] = function(args, callback, error) {
+ var body, headers;
+ if (args == null) args = {};
+ if ((typeof args) === "function") {
+ error = callback;
+ callback = args;
+ args = {};
+ }
+ if (error == null) {
+ error = function(xhr, textStatus, error) {
+ return console.log(xhr, textStatus, error);
+ };
+ }
+ if (callback == null) {
+ callback = function(data) {
+ return console.log(data);
+ };
+ }
+ if (args.headers != null) {
+ headers = args.headers;
+ delete args.headers;
+ }
+ if (args.body != null) {
+ body = args.body;
+ delete args.body;
+ }
+ return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
+ };
+
+ SwaggerOperation.prototype.urlify = function(args) {
+ var param, url, _i, _len, _ref;
+ url = this.resource.basePath + this.path;
+ url = url.replace('{format}', 'json');
+ _ref = this.parameters;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ param = _ref[_i];
+ if (param.paramType === 'path') {
+ if (args[param.name]) {
+ url = url.replace("{" + param.name + "}", args[param.name]);
+ delete args[param.name];
+ } else {
+ throw "" + param.name + " is a required path param.";
+ }
+ }
+ }
+ if (this.resource.api.api_key != null) {
+ args['api_key'] = this.resource.api.api_key;
+ }
+ url += "?" + $.param(args);
+ return url;
+ };
+
+ SwaggerOperation.prototype.help = function() {
+ var parameter, _i, _len, _ref;
+ _ref = this.parameters;
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ parameter = _ref[_i];
+ console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
+ }
+ return this;
+ };
+
+ return SwaggerOperation;
+
+ })();
+
+ SwaggerRequest = (function() {
+
+ function SwaggerRequest(type, url, headers, body, callback, error, operation) {
+ var obj,
+ _this = this;
+ this.type = type;
+ this.url = url;
+ this.headers = headers;
+ this.body = body;
+ this.callback = callback;
+ this.error = error;
+ this.operation = operation;
+ if (this.type == null) {
+ throw "SwaggerRequest type is required (get/post/put/delete).";
+ }
+ if (this.url == null) throw "SwaggerRequest url is required.";
+ if (this.callback == null) throw "SwaggerRequest callback is required.";
+ if (this.error == null) throw "SwaggerRequest error callback is required.";
+ if (this.operation == null) throw "SwaggerRequest operation is required.";
+ if (this.operation.resource.api.verbose) console.log(this.asCurl());
+ this.headers || (this.headers = {});
+ if (this.operation.resource.api.api_key != null) {
+ this.headers.api_key = this.operation.resource.api.api_key;
+ }
+ if (this.headers.mock == null) {
+ obj = {
+ type: this.type,
+ url: this.url,
+ data: JSON.stringify(this.body),
+ dataType: 'json',
+ error: function(xhr, textStatus, error) {
+ return this.error(xhr, textStatus, error);
+ },
+ success: function(data) {
+ return _this.callback(data);
+ }
+ };
+ if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
+ obj.contentType = "application/json";
+ }
+ $.ajax(obj);
+ }
+ }
+
+ SwaggerRequest.prototype.asCurl = function() {
+ var header_args, k, v;
+ header_args = (function() {
+ var _ref, _results;
+ _ref = this.headers;
+ _results = [];
+ for (k in _ref) {
+ v = _ref[k];
+ _results.push("--header \"" + k + ": " + v + "\"");
+ }
+ return _results;
+ }).call(this);
+ return "curl " + (header_args.join(" ")) + " " + this.url;
+ };
+
+ return SwaggerRequest;
+
+ })();
+
+ window.SwaggerApi = SwaggerApi;
+
+ window.SwaggerResource = SwaggerResource;
+
+ window.SwaggerOperation = SwaggerOperation;
+
+ window.SwaggerRequest = SwaggerRequest;
+
+}).call(this);
View
110 lib/grounds/template.js
@@ -0,0 +1,110 @@
+(function() {
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['template.html'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+
+function program1(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n <li class='resource'>\n <h2>";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</h2>\n <ul class='operations'>\n ";
+ foundHelper = helpers.operation;
+ stack1 = foundHelper || depth0.operation;
+ stack2 = helpers.each;
+ tmp1 = self.program(2, program2, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n </ul>\n </li>\n ";
+ return buffer;}
+function program2(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n <li class='operation ";
+ foundHelper = helpers.httpMethod;
+ stack1 = foundHelper || depth0.httpMethod;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'>\n <header>\n <h3>\n <a class='";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'>";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</a>\n </h3>\n <ul class='options'>\n <li>\n ";
+ foundHelper = helpers.summary;
+ stack1 = foundHelper || depth0.summary;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "summary", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "\n <li></li>\n </li>\n </ul>\n </header>\n <form>\n <span class='nickname'>";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</span>\n <span class='path'>";
+ foundHelper = helpers.path;
+ stack1 = foundHelper || depth0.path;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "path", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</span>\n <table>\n <thead>\n <tr>\n <td>Parameter</td>\n <td>Value</td>\n <td>Description</td>\n </tr>\n </thead>\n <tbody>\n ";
+ foundHelper = helpers.parameter;
+ stack1 = foundHelper || depth0.parameter;
+ stack2 = helpers.each;
+ tmp1 = self.program(3, program3, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n </tbody>\n </table>\n </form>\n <div class='response'></div>\n </li>\n ";
+ return buffer;}
+function program3(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <tr>\n <td>";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n <td>";
+ foundHelper = helpers.value;
+ stack1 = foundHelper || depth0.value;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "value", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n <td>";
+ foundHelper = helpers.value;
+ stack1 = foundHelper || depth0.value;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "value", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n </tr>\n ";
+ return buffer;}
+
+ buffer += "<h1>";
+ foundHelper = helpers.basePath;
+ stack1 = foundHelper || depth0.basePath;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "basePath", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</h1>\n<ul class='resources'>\n ";
+ foundHelper = helpers.resource;
+ stack1 = foundHelper || depth0.resource;
+ stack2 = helpers.each;
+ tmp1 = self.program(1, program1, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n</ul>";
+ return buffer;});
+})();
View
4 lib/swagger-ui-spec.js
@@ -20,9 +20,9 @@
return expect(ui.ready).toBe(true);
});
});
- return it("defines window.swagger_template", function() {
+ return it("has access to the precompiled Handlebars template", function() {
return runs(function() {
- return expect(window.swagger_template).toBeDefined();
+ return expect(Handlebars.templates['template.html']).toBeDefined();
});
});
});
View
628 lib/swagger-ui.js
@@ -1,5 +1,262 @@
+// lib/handlebars/base.js
+var Handlebars = {};
+
+Handlebars.VERSION = "1.0.beta.6";
+
+Handlebars.helpers = {};
+Handlebars.partials = {};
+
+Handlebars.registerHelper = function(name, fn, inverse) {
+ if(inverse) { fn.not = inverse; }
+ this.helpers[name] = fn;
+};
+
+Handlebars.registerPartial = function(name, str) {
+ this.partials[name] = str;
+};
+
+Handlebars.registerHelper('helperMissing', function(arg) {
+ if(arguments.length === 2) {
+ return undefined;
+ } else {
+ throw new Error("Could not find property '" + arg + "'");
+ }
+});
+
+var toString = Object.prototype.toString, functionType = "[object Function]";
+
+Handlebars.registerHelper('blockHelperMissing', function(context, options) {
+ var inverse = options.inverse || function() {}, fn = options.fn;
+
+
+ var ret = "";
+ var type = toString.call(context);
+
+ if(type === functionType) { context = context.call(this); }
+
+ if(context === true) {
+ return fn(this);
+ } else if(context === false || context == null) {
+ return inverse(this);
+ } else if(type === "[object Array]") {
+ if(context.length > 0) {
+ for(var i=0, j=context.length; i<j; i++) {
+ ret = ret + fn(context[i]);
+ }
+ } else {
+ ret = inverse(this);
+ }
+ return ret;
+ } else {
+ return fn(context);
+ }
+});
+
+Handlebars.registerHelper('each', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ var ret = "";
+
+ if(context && context.length > 0) {
+ for(var i=0, j=context.length; i<j; i++) {
+ ret = ret + fn(context[i]);
+ }
+ } else {
+ ret = inverse(this);
+ }
+ return ret;
+});
+
+Handlebars.registerHelper('if', function(context, options) {
+ var type = toString.call(context);
+ if(type === functionType) { context = context.call(this); }
+
+ if(!context || Handlebars.Utils.isEmpty(context)) {
+ return options.inverse(this);
+ } else {
+ return options.fn(this);
+ }
+});
+
+Handlebars.registerHelper('unless', function(context, options) {
+ var fn = options.fn, inverse = options.inverse;
+ options.fn = inverse;
+ options.inverse = fn;
+
+ return Handlebars.helpers['if'].call(this, context, options);
+});
+
+Handlebars.registerHelper('with', function(context, options) {
+ return options.fn(context);
+});
+
+Handlebars.registerHelper('log', function(context) {
+ Handlebars.log(context);
+});
+;
+// lib/handlebars/utils.js
+Handlebars.Exception = function(message) {
+ var tmp = Error.prototype.constructor.apply(this, arguments);
+
+ for (var p in tmp) {
+ if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
+ }
+
+ this.message = tmp.message;
+};
+Handlebars.Exception.prototype = new Error;
+
+// Build out our basic SafeString type
+Handlebars.SafeString = function(string) {
+ this.string = string;
+};
+Handlebars.SafeString.prototype.toString = function() {
+ return this.string.toString();
+};
+
+(function() {
+ var escape = {
+ "<": "&lt;",
+ ">": "&gt;",
+ '"': "&quot;",
+ "'": "&#x27;",
+ "`": "&#x60;"
+ };
+
+ var badChars = /&(?!\w+;)|[<>"'`]/g;
+ var possible = /[&<>"'`]/;
+
+ var escapeChar = function(chr) {
+ return escape[chr] || "&amp;";
+ };
+
+ Handlebars.Utils = {
+ escapeExpression: function(string) {
+ // don't escape SafeStrings, since they're already safe
+ if (string instanceof Handlebars.SafeString) {
+ return string.toString();
+ } else if (string == null || string === false) {
+ return "";
+ }
+
+ if(!possible.test(string)) { return string; }
+ return string.replace(badChars, escapeChar);
+ },
+
+ isEmpty: function(value) {
+ if (typeof value === "undefined") {
+ return true;
+ } else if (value === null) {
+ return true;
+ } else if (value === false) {
+ return true;
+ } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ };
+})();;
+// lib/handlebars/runtime.js
+Handlebars.VM = {
+ template: function(templateSpec) {
+ // Just add water
+ var container = {
+ escapeExpression: Handlebars.Utils.escapeExpression,
+ invokePartial: Handlebars.VM.invokePartial,
+ programs: [],
+ program: function(i, fn, data) {
+ var programWrapper = this.programs[i];
+ if(data) {
+ return Handlebars.VM.program(fn, data);
+ } else if(programWrapper) {
+ return programWrapper;
+ } else {
+ programWrapper = this.programs[i] = Handlebars.VM.program(fn);
+ return programWrapper;
+ }
+ },
+ programWithDepth: Handlebars.VM.programWithDepth,
+ noop: Handlebars.VM.noop
+ };
+
+ return function(context, options) {
+ options = options || {};
+ return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
+ };
+ },
+
+ programWithDepth: function(fn, data, $depth) {
+ var args = Array.prototype.slice.call(arguments, 2);
+
+ return function(context, options) {
+ options = options || {};
+
+ return fn.apply(this, [context, options.data || data].concat(args));
+ };
+ },
+ program: function(fn, data) {
+ return function(context, options) {
+ options = options || {};
+
+ return fn(context, options.data || data);
+ };
+ },
+ noop: function() { return ""; },
+ invokePartial: function(partial, name, context, helpers, partials, data) {
+ options = { helpers: helpers, partials: partials, data: data };
+
+ if(partial === undefined) {
+ throw new Handlebars.Exception("The partial " + name + " could not be found");
+ } else if(partial instanceof Function) {
+ return partial(context, options);
+ } else if (!Handlebars.compile) {
+ throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
+ } else {
+ partials[name] = Handlebars.compile(partial);
+ return partials[name](context, options);
+ }
+ }
+};
+
+Handlebars.template = Handlebars.VM.template;
+;
(function() {
- var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource, SwaggerUi, functionType, toString,
+ var SwaggerUi,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+
+ SwaggerUi = (function() {
+
+ SwaggerUi.prototype.dom_id = "swagger_ui";
+
+ function SwaggerUi(options) {
+ if (options == null) options = {};
+ this.render = __bind(this.render, this);
+ if (options.dom_id != null) {
+ this.dom_id = options.dom_id;
+ delete options.dom_id;
+ }
+ options.success = this.render;
+ this.api = new SwaggerApi(options);
+ }
+
+ SwaggerUi.prototype.render = function() {
+ if (!($("#" + this.dom_id).length > 0)) {
+ $('body').append("<div id='" + this.dom_id + "'></div>");
+ }
+ this.ready = true;
+ return this;
+ };
+
+ return SwaggerUi;
+
+ })();
+
+ window.SwaggerUi = SwaggerUi;
+
+}).call(this);
+(function() {
+ var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
SwaggerApi = (function() {
@@ -299,263 +556,114 @@
window.SwaggerRequest = SwaggerRequest;
- window.Handlebars = {};
-
- Handlebars.VERSION = "1.0.beta.6";
-
- Handlebars.helpers = {};
-
- Handlebars.partials = {};
-
- Handlebars.registerHelper = function(name, fn, inverse) {
- if (inverse) fn.not = inverse;
- return this.helpers[name] = fn;
- };
-
- Handlebars.registerPartial = function(name, str) {
- return this.partials[name] = str;
- };
-
- Handlebars.registerHelper("helperMissing", function(arg) {
- if (arguments.length === 2) {
- return undefined;
- } else {
- throw new Error("Could not find property '" + arg + "'");
- }
- });
-
- toString = Object.prototype.toString;
-
- functionType = "[object Function]";
-
- Handlebars.registerHelper("blockHelperMissing", function(context, options) {
- var fn, i, inverse, j, ret, type;
- inverse = options.inverse || function() {};
- fn = options.fn;
- ret = "";
- type = toString.call(context);
- if (type === functionType) context = context.call(this);
- if (context === true) {
- return fn(this);
- } else if (context === false || !(context != null)) {
- return inverse(this);
- } else if (type === "[object Array]") {
- if (context.length > 0) {
- i = 0;
- j = context.length;
- while (i < j) {
- ret = ret + fn(context[i]);
- i++;
- }
- } else {
- ret = inverse(this);
- }
- return ret;
- } else {
- return fn(context);
- }
- });
-
- Handlebars.registerHelper("each", function(context, options) {
- var fn, i, inverse, j, ret;
- fn = options.fn;
- inverse = options.inverse;
- ret = "";
- if (context && context.length > 0) {
- i = 0;
- j = context.length;
- while (i < j) {
- ret = ret + fn(context[i]);
- i++;
- }
- } else {
- ret = inverse(this);
- }
- return ret;
- });
-
- Handlebars.registerHelper("if", function(context, options) {
- var type;
- type = toString.call(context);
- if (type === functionType) context = context.call(this);
- if (!context || Handlebars.Utils.isEmpty(context)) {
- return options.inverse(this);
- } else {
- return options.fn(this);
- }
- });
-
- Handlebars.registerHelper("unless", function(context, options) {
- var fn, inverse;
- fn = options.fn;
- inverse = options.inverse;
- options.fn = inverse;
- options.inverse = fn;
- return Handlebars.helpers["if"].call(this, context, options);
- });
-
- Handlebars.registerHelper("with", function(context, options) {
- return options.fn(context);
- });
-
- Handlebars.registerHelper("log", function(context) {
- return Handlebars.log(context);
- });
-
- Handlebars.Exception = function(message) {
- var p, tmp;
- tmp = Error.prototype.constructor.apply(this, arguments);
- for (p in tmp) {
- if (tmp.hasOwnProperty(p)) this[p] = tmp[p];
- }
- return this.message = tmp.message;
- };
-
- Handlebars.Exception.prototype = new Error;
-
- Handlebars.SafeString = function(string) {
- return this.string = string;
- };
-
- Handlebars.SafeString.prototype.toString = function() {
- return this.string.toString();
- };
-
- (function() {
- var badChars, escape, escapeChar, possible;
- escape = {
- "<": "&lt;",
- ">": "&gt;",
- "\"": "&quot;",
- "'": "&#x27;",
- "`": "&#x60;"
- };
- badChars = /&(?!\w+;)|[<>"'`]/g;
- possible = /[&<>"'`]/;
- escapeChar = function(chr) {
- return escape[chr] || "&amp;";
- };
- return Handlebars.Utils = {
- escapeExpression: function(string) {
- if (string instanceof Handlebars.SafeString) {
- return string.toString();
- } else {
- if (!(string != null) || string === false) return "";
- }
- if (!possible.test(string)) return string;
- return string.replace(badChars, escapeChar);
- },
- isEmpty: function(value) {
- if (typeof value === "undefined") {
- return true;
- } else if (value === null) {
- return true;
- } else if (value === false) {
- return true;
- } else if (Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
- return true;
- } else {
- return false;
- }
- }
- };
- })();
-
- Handlebars.VM = {
- template: function(templateSpec) {
- var container;
- container = {
- escapeExpression: Handlebars.Utils.escapeExpression,
- invokePartial: Handlebars.VM.invokePartial,
- programs: [],
- program: function(i, fn, data) {
- var programWrapper;
- programWrapper = this.programs[i];
- if (data) {
- return Handlebars.VM.program(fn, data);
- } else if (programWrapper) {
- return programWrapper;
- } else {
- programWrapper = this.programs[i] = Handlebars.VM.program(fn);
- return programWrapper;
- }
- },
- programWithDepth: Handlebars.VM.programWithDepth,
- noop: Handlebars.VM.noop
- };
- return function(context, options) {
- options = options || {};
- return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
- };
- },
- programWithDepth: function(fn, data, $depth) {
- var args;
- args = Array.prototype.slice.call(arguments, 2);
- return function(context, options) {
- options = options || {};
- return fn.apply(this, [context, options.data || data].concat(args));
- };
- },
- program: function(fn, data) {
- return function(context, options) {
- options = options || {};
- return fn(context, options.data || data);
- };
- },
- noop: function() {
- return "";
- },
- invokePartial: function(partial, name, context, helpers, partials, data) {
- var options;
- options = {
- helpers: helpers,
- partials: partials,
- data: data
- };
- if (partial === undefined) {
- throw new Handlebars.Exception("The partial " + name + " could not be found");
- } else if (partial instanceof Function) {
- return partial(context, options);
- } else if (!Handlebars.compile) {
- throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
- } else {
- partials[name] = Handlebars.compile(partial);
- return partials[name](context, options);
- }
- }
- };
-
- Handlebars.template = Handlebars.VM.template;
-
- window.swagger_template = "<h1>{{basePath}}</h1><ul class='resources'> {{#each resource}} <li class='resource'> <h2>{{name}}</h2> <ul class='operations'> {{#each operation}} <li class='operation {{httpMethod}}'> <header> <h3> <a class='{{nickname}}'>{{nickname}}</a> </h3> <ul class='options'> <li> {{summary}} <li></li> </li> </ul> </header> <form> <span class='nickname'>{{nickname}}</span> <span class='path'>{{path}}</span> <table> <thead> <tr> <td>Parameter</td> <td>Value</td> <td>Description</td> </tr> </thead> <tbody> {{#each parameter}} <tr> <td>{{name}}</td> <td>{{value}}</td> <td>{{value}}</td> </tr> {{each}} </tbody> </table> </form> <div class='response'></div> </li> {{each}} </ul> </li> {{/each}}</ul>";
-
- SwaggerUi = (function() {
-
- SwaggerUi.prototype.dom_id = "swagger_ui";
-
- function SwaggerUi(options) {
- if (options == null) options = {};
- this.render = __bind(this.render, this);
- if (options.dom_id != null) {
- this.dom_id = options.dom_id;
- delete options.dom_id;
- }
- options.success = this.render;
- this.api = new SwaggerApi(options);
- }
-
- SwaggerUi.prototype.render = function() {
- if (!($("#" + this.dom_id).length > 0)) {
- $('body').append("<div id='" + this.dom_id + "'></div>");
- }
- this.ready = true;
- return this;
- };
-
- return SwaggerUi;
-
- })();
-
- window.SwaggerUi = SwaggerUi;
-
}).call(this);
+(function() {
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['template.html'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+
+function program1(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n <li class='resource'>\n <h2>";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</h2>\n <ul class='operations'>\n ";
+ foundHelper = helpers.operation;
+ stack1 = foundHelper || depth0.operation;
+ stack2 = helpers.each;
+ tmp1 = self.program(2, program2, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n </ul>\n </li>\n ";
+ return buffer;}
+function program2(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n <li class='operation ";
+ foundHelper = helpers.httpMethod;
+ stack1 = foundHelper || depth0.httpMethod;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'>\n <header>\n <h3>\n <a class='";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'>";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</a>\n </h3>\n <ul class='options'>\n <li>\n ";
+ foundHelper = helpers.summary;
+ stack1 = foundHelper || depth0.summary;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "summary", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "\n <li></li>\n </li>\n </ul>\n </header>\n <form>\n <span class='nickname'>";
+ foundHelper = helpers.nickname;
+ stack1 = foundHelper || depth0.nickname;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "nickname", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</span>\n <span class='path'>";
+ foundHelper = helpers.path;
+ stack1 = foundHelper || depth0.path;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "path", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</span>\n <table>\n <thead>\n <tr>\n <td>Parameter</td>\n <td>Value</td>\n <td>Description</td>\n </tr>\n </thead>\n <tbody>\n ";
+ foundHelper = helpers.parameter;
+ stack1 = foundHelper || depth0.parameter;
+ stack2 = helpers.each;
+ tmp1 = self.program(3, program3, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n </tbody>\n </table>\n </form>\n <div class='response'></div>\n </li>\n ";
+ return buffer;}
+function program3(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <tr>\n <td>";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n <td>";
+ foundHelper = helpers.value;
+ stack1 = foundHelper || depth0.value;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "value", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n <td>";
+ foundHelper = helpers.value;
+ stack1 = foundHelper || depth0.value;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "value", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n </tr>\n ";
+ return buffer;}
+
+ buffer += "<h1>";
+ foundHelper = helpers.basePath;
+ stack1 = foundHelper || depth0.basePath;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "basePath", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</h1>\n<ul class='resources'>\n ";
+ foundHelper = helpers.resource;
+ stack1 = foundHelper || depth0.resource;
+ stack2 = helpers.each;
+ tmp1 = self.program(1, program1, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n</ul>";
+ return buffer;});
+})();
View
1 node_modules/.bin/handlebars
View
11 node_modules/handlebars/.npmignore
@@ -0,0 +1,11 @@
+.DS_Store
+.gitignore
+.rvmrc
+Gemfile
+Gemfile.lock
+Rakefile
+bench/*
+dist/*
+spec/*
+src/*
+vendor/*
View
20 node_modules/handlebars/LICENSE
@@ -0,0 +1,20 @@
+Copyright (C) 2011 by Yehuda Katz
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
View
315 node_modules/handlebars/README.markdown
@@ -0,0 +1,315 @@
+[![Build Status](https://secure.travis-ci.org/wycats/handlebars.js.png)](http://travis-ci.org/wycats/handlebars.js)
+
+Handlebars.js
+=============
+
+Handlebars.js is an extension to the [Mustache templating language](http://mustache.github.com/) created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.
+
+Checkout the official Handlebars docs site at [http://www.handlebarsjs.com](http://www.handlebarsjs.com).
+
+
+Installing
+----------
+Installing Handlebars is easy. Simply [download the package from GitHub](https://github.com/wycats/handlebars.js/archives/master) and add it to your web pages (you should usually use the most recent version).
+
+Usage
+-----
+In general, the syntax of Handlebars.js templates is a superset of Mustache templates. For basic syntax, check out the [Mustache manpage](http://mustache.github.com/mustache.5.html).
+
+Once you have a template, use the Handlebars.compile method to compile the template into a function. The generated function takes a context argument, which will be used to render the template.
+
+```js
+var source = "<p>Hello, my name is {{name}}. I am from {{hometown}}. I have " +
+ "{{kids.length}} kids:</p>" +
+ "<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>";
+var template = Handlebars.compile(source);
+
+var data = { "name": "Alan", "hometown": "Somewhere, TX",
+ "kids": [{"name": "Jimmy", "age": "12"}, {"name": "Sally", "age": "4"}]};
+var result = template(data);
+
+// Would render:
+// <p>Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:</p>
+// <ul>
+// <li>Jimmy is 12</li>
+// <li>Sally is 4</li>
+// </ul>
+```
+
+
+Registering Helpers
+-------------------
+
+You can register helpers that Handlebars will use when evaluating your
+template. Here's an example, which assumes that your objects have a URL
+embedded in them, as well as the text for a link:
+
+```js
+Handlebars.registerHelper('link_to', function(context) {
+ return "<a href='" + context.url + "'>" + context.body + "</a>";
+});
+
+var context = { posts: [{url: "/hello-world", body: "Hello World!"}] };
+var source = "<ul>{{#posts}}<li>{{{link_to this}}}</li>{{/posts}}</ul>"
+
+var template = Handlebars.compile(source);
+template(context);
+
+// Would render:
+//
+// <ul>
+// <li><a href='/hello-world'>Hello World!</a></li>
+// </ul>
+```
+
+Escaping
+--------
+
+By default, the `{{expression}}` syntax will escape its contents. This
+helps to protect you against accidental XSS problems caused by malicious
+data passed from the server as JSON.
+
+To explicitly *not* escape the contents, use the triple-mustache
+(`{{{}}}`). You have seen this used in the above example.
+
+
+Differences Between Handlebars.js and Mustache
+----------------------------------------------
+Handlebars.js adds a couple of additional features to make writing templates easier and also changes a tiny detail of how partials work.
+
+### Paths
+
+Handlebars.js supports an extended expression syntax that we call paths. Paths are made up of typical expressions and . characters. Expressions allow you to not only display data from the current context, but to display data from contexts that are descendents and ancestors of the current context.
+
+To display data from descendent contexts, use the `.` character. So, for example, if your data were structured like:
+
+```js
+var data = {"person": { "name": "Alan" }, company: {"name": "Rad, Inc." } };
+```
+
+you could display the person's name from the top-level context with the following expression:
+
+```
+{{person.name}}
+```
+
+You can backtrack using `../`. For example, if you've already traversed into the person object you could still display the company's name with an expression like `{{../company.name}}`, so:
+
+```
+{{#person}}{{name}} - {{../company.name}}{{/person}}
+```
+
+would render:
+
+```
+Alan - Rad, Inc.
+```
+
+### Strings
+
+When calling a helper, you can pass paths or Strings as parameters. For
+instance:
+
+```js
+Handlebars.registerHelper('link_to', function(title, context) {
+ return "<a href='/posts" + context.id + "'>" + title + "</a>"
+});
+
+var context = { posts: [{url: "/hello-world", body: "Hello World!"}] };
+var source = '<ul>{{#posts}}<li>{{{link_to "Post" this}}}</li>{{/posts}}</ul>'
+
+var template = Handlebars.compile(source);
+template(context);
+
+// Would render:
+//
+// <ul>
+// <li><a href='/hello-world'>Post!</a></li>
+// </ul>
+```
+
+When you pass a String as a parameter to a helper, the literal String
+gets passed to the helper function.
+
+
+### Block Helpers
+
+Handlebars.js also adds the ability to define block helpers. Block helpers are functions that can be called from anywhere in the template. Here's an example:
+
+```js
+var source = "<ul>{{#people}}<li>{{{#link}}}{{name}}{{/link}}</li>{{/people}}</ul>";
+Handlebars.registerHelper('link', function(context, fn) {
+ return '<a href="/people/' + this.__get__("id") + '">' + fn(this) + '</a>';
+});
+var template = Handlebars.compile(source);
+
+var data = { "people": [
+ { "name": "Alan", "id": 1 },
+ { "name": "Yehuda", "id": 2 }
+ ]};
+template(data);
+
+// Should render:
+// <ul>
+// <li><a href="/people/1">Alan</a></li>
+// <li><a href="/people/2">Yehuda</a></li>
+// </ul>
+```
+
+Whenever the block helper is called it is given two parameters, the argument that is passed to the helper, or the current context if no argument is passed and the compiled contents of the block. Inside of the block helper the value of `this` is the current context, wrapped to include a method named `__get__` that helps translate paths into values within the helpers.
+
+### Partials
+
+You can register additional templates as partials, which will be used by
+Handlebars when it encounters a partial (`{{> partialName}}`). Partials
+can either be String templates or compiled template functions. Here's an
+example:
+
+```js
+var source = "<ul>{{#people}}<li>{{> link}}</li>{{/people}}</ul>";
+
+Handlebars.registerPartial('link', '<a href="/people/{{id}}">{{name}}</a>')
+var template = Handlebars.compile(source);
+
+var data = { "people": [
+ { "name": "Alan", "id": 1 },
+ { "name": "Yehuda", "id": 2 }
+ ]};
+
+template(data);
+
+// Should render:
+// <ul>
+// <li><a href="/people/1">Alan</a></li>
+// <li><a href="/people/2">Yehuda</a></li>
+// </ul>
+```
+
+### Comments
+
+You can add comments to your templates with the following syntax:
+
+```js
+{{! This is a comment }}
+```
+
+You can also use real html comments if you want them to end up in the output.
+
+```html
+<div>
+ {{! This comment will not end up in the output }}
+ <!-- This comment will show up in the output -->
+</div>
+```
+
+
+Precompiling Templates
+----------------------
+
+Handlebars allows templates to be precompiled and included as javascript
+code rather than the handlebars template allowing for faster startup time.
+
+### Installation
+The precompiler script may be installed via npm using the `npm install -g handlebars`
+command.
+
+### Usage
+
+<pre>
+Precompile handlebar templates.
+Usage: handlebars template...
+
+Options:
+ -f, --output Output File [string]
+ -k, --known Known helpers [string]
+ -o, --knownOnly Known helpers only [boolean]
+ -m, --min Minimize output [boolean]
+ -s, --simple Output template function only. [boolean]
+ -r, --root Template root. Base value that will be stripped from template names. [string]
+</pre>
+
+If using the precompiler's normal mode, the resulting templates will be stored
+to the `Handlebars.templates` object using the relative template name sans the
+extension. These templates may be executed in the same manner as templates.
+
+If using the simple mode the precompiler will generate a single javascript method.
+To execute this method it must be passed to the using the `Handlebars.template`
+method and the resulting object may be as normal.
+
+### Optimizations
+
+- Rather than using the full _handlebars.js_ library, implementations that
+ do not need to compile templates at runtime may include _handlebars.vm.js_
+ whose min+gzip size is approximately 1k.
+- If a helper is known to exist in the target environment they may be defined
+ using the `--known name` argument may be used to optimize accesses to these
+ helpers for size and speed.
+- When all helpers are known in advance the `--knownOnly` argument may be used
+ to optimize all block helper references.
+
+
+Performance
+-----------
+
+In a rough performance test, precompiled Handlebars.js templates (in the original version of Handlebars.js) rendered in about half the time of Mustache templates. It would be a shame if it were any other way, since they were precompiled, but the difference in architecture does have some big performance advantages. Justin Marney, a.k.a. [gotascii](http://github.com/gotascii), confirmed that with an [independent test](http://sorescode.com/2010/09/12/benchmarks.html). The rewritten Handlebars (current version) is faster than the old version, and we will have some benchmarks in the near future.
+
+
+Building
+--------
+
+To build handlebars, just run `rake release`, and you will get two files
+in the `dist` directory.
+
+
+Upgrading
+---------
+
+When upgrading from the Handlebars 0.9 series, be aware that the
+signature for passing custom helpers or partials to templates has
+changed.
+
+Instead of:
+
+```js
+template(context, helpers, partials, [data])
+```
+
+Use:
+
+```js
+template(context, {helpers: helpers, partials: partials, data: data})
+```
+
+Known Issues
+------------
+* Handlebars.js can be cryptic when there's an error while rendering.
+
+Handlebars in the Wild
+-----------------
+* [jblotus](http://github.com/jblotus) created [http://tryhandlebarsjs.com](http://tryhandlebarsjs.com) for anyone who would
+like to try out Handlebars.js in their browser.
+* Don Park wrote an Express.js view engine adapter for Handlebars.js called [hbs](http://github.com/donpark/hbs).
+* [sammy.js](http://github.com/quirkey/sammy) by Aaron Quint, a.k.a. quirkey, supports Handlebars.js as one of its template plugins.
+* [SproutCore](http://www.sproutcore.com) uses Handlebars.js as its main templating engine, extending it with automatic data binding support.
+* [Ember.js](http://www.emberjs.com) makes Handlebars.js the primary way to structure your views, also with automatic data binding support.
+* Les Hill (@leshill) wrote a Rails Asset Pipeline gem named [handlebars_assets](http://github.com/leshill/handlebars_assets).
+
+Helping Out
+-----------
+To build Handlebars.js you'll need a few things installed.
+
+* Node.js
+* Jison, for building the compiler - `npm install jison`
+* Ruby
+* therubyracer, for running tests - `gem install therubyracer`
+* rspec, for running tests - `gem install rspec`
+
+There's a Gemfile in the repo, so you can run `bundle` to install rspec and therubyracer if you've got bundler installed.
+
+To build Handlebars.js from scratch, you'll want to run `rake compile` in the root of the project. That will build Handlebars and output the results to the dist/ folder. To run tests, run `rake spec`. You can also run our set of benchmarks with `rake bench`.
+
+If you notice any problems, please report them to the GitHub issue tracker at [http://github.com/wycats/handlebars.js/issues](http://github.com/wycats/handlebars.js/issues). Feel free to contact commondream or wycats through GitHub with any other questions or feature requests. To submit changes fork the project and send a pull request.
+
+License
+-------
+Handlebars.js is released under the MIT license.
View
139 node_modules/handlebars/bin/handlebars
@@ -0,0 +1,139 @@
+#!/usr/bin/env node
+
+var optimist = require('optimist')
+ .usage('Precompile handlebar templates.\nUsage: $0 template...', {
+ 'f': {
+ 'type': 'string',
+ 'description': 'Output File',
+ 'alias': 'output'
+ },
+ 'k': {
+ 'type': 'string',
+ 'description': 'Known helpers',
+ 'alias': 'known'
+ },
+ 'o': {
+ 'type': 'boolean',
+ 'description': 'Known helpers only',
+ 'alias': 'knownOnly'
+ },
+ 'm': {
+ 'type': 'boolean',
+ 'description': 'Minimize output',
+ 'alias': 'min'
+ },
+ 's': {
+ 'type': 'boolean',
+ 'description': 'Output template function only.',
+ 'alias': 'simple'
+ },
+ 'r': {
+ 'type': 'string',
+ 'description': 'Template root. Base value that will be stripped from template names.',
+ 'alias': 'root'
+ }
+ })
+
+ .check(function(argv) {
+ var template = [0];
+ if (!argv._.length) {
+ throw 'Must define at least one template or directory.';
+ }
+
+ argv._.forEach(function(template) {
+ try {
+ fs.statSync(template);
+ } catch (err) {
+ throw 'Unable to open template file "' + template + '"';
+ }
+ });
+ })
+ .check(function(argv) {
+ if (argv.simple && argv.min) {
+ throw 'Unable to minimze simple output';
+ }
+ if (argv.simple && (argv._.length !== 1 || fs.statSync(argv._[0]).isDirectory())) {
+ throw 'Unable to output multiple templates in simple mode';
+ }