Permalink
Browse files

Integrated mauricemach/zappa@122 with minor corrections.

  • Loading branch information...
1 parent 382aa9f commit 6804afc0af4fea2a4090651d8c6d7b3455bc2aa0 @shimaore shimaore committed Apr 24, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 examples/form_post.coffee
View
@@ -0,0 +1,30 @@
+# This example shows how to use the default layout to render
+# a form and retrieve data from its submission.
+
+require('./zappajs') ->
+ @enable 'default layout'
+ @use 'bodyParser'
+
+ @get '/': ->
+ @render index: {}
+
+ @post '/widgets': ->
+ @render widgets: { form: @body }
+
+ @view index: ->
+ @title = 'My Form'
+ h1 @title
+ form method: 'post', action: '/widgets', ->
+ input
+ id: 'widget_name'
+ type: 'text'
+ name: 'widget_name'
+ placeholder: 'widget name'
+ size: 50
+ value: @widget_name
+ button 'create widget'
+
+ @view widgets: ->
+ @title = 'Widgets'
+ h1 @title
+ p @form.widget_name

0 comments on commit 6804afc

Please sign in to comment.