                      a valid template path like described
                      <a href=learn.koding.com target=_blank>here</a>."
 
-        else if template?.content?
-
-          content   = atob template.content
+        else if res?.content?
+
+          content   = atob res.content
           template  = analyzeTemplate content
           {message} = template
+          template.details = res
 
           if template.valid then @addTo container,
             button        :

          cssClass      : 'solid compact green nav next'
          callback      : ->

            {title}  = views.input_title.getData()
            template = views.editorView.getValue()

            updateStackTemplate {
              title, template, credential, stackTemplate
            }, (err, _stackTemplate) ->
              return  if showError err

              callback {
                stackTemplate: _stackTemplate, credential, provider
              }

      return container



  updateStackTemplate = (data, callback) ->

    { template, templateDetails, credential
      title, stackTemplate, machines } = data

    title     or= 'Default stack template'
    credentials = [credential.publicKey]  if credential

    if stackTemplate
      dataToUpdate = if machines \
        then {machines} else {title, template, credentials, templateDetails}
      stackTemplate.update dataToUpdate, (err) ->
        callback err, stackTemplate
    else
      remote.api.JStackTemplate.create {
        title, template, credentials, templateDetails
      }, callback


