   pilers =
     raw: (ob, cb) -> cb null, ob.raw
     object: (ob, cb) ->
-      code = ""
-      for k, v of ob.object
-        code += "window['#{ k }'] = #{ OB.stringify v };\n"
-      cb null, code
+      cb null, toGlobals ob.object
     exec: (ob, cb) ->
       cb null, executableFrom ob.object
     file: (ob, cb) ->

  Type: JSPile
  contentType: "application/javascript"

  addOb: defNs (ns, ob) ->
    pile = @getPile ns
    pile.addOb ob

  setDynamicHelper: (app) ->
    app.dynamicHelpers renderScriptTags: (req, res) => =>
      bundle = @renderTags.apply this, arguments
      inline = ""

      if res._responseObs
        for ob in res._responseObs
          inline += toGlobals ob

      if res._responseFns
        for fn in res._responseFns
          inline += executableFrom fn

      bundle + wrapInScriptTagInline inline

  setMiddleware: (app) ->
    responseExec = (fn) ->
      # "this" is the response object
      this._responseFns.push fn

    responseOb = (ob) ->
      this._responseObs.push ob

    # Middleware that adds add & exec methods to response objects.
    app.use (req, res, next) ->
      res._responseFns ?= []
      res._responseObs ?= []

      # TODO: deprecate res.exec
      res.exec = res.addExec = responseExec
      res.addOb = responseOb

      next()

class CSSManager extends PileManager
