import{safeHtml}from'common-tags'import{make_form_view}from'simple-server-side-rosmaro-forms'letviewview=make_form_view()//or if instead of "_csrf" you'd like to use "token"view=make_form_view({csrf_field_name: "token"})constmake_enter_name_leaf=view(()=>({render(){returnsafeHtml` Enter your name: <input type="text" name="${this.pname('name')}"> <input type="submit"> `},handle(params){this.follow("entered_name",{...this.context,name: params['name']})}}))constenter_name_leaf=make_enter_name_leaf()
Handling forms
import{render_model}from'simple-server-side-rosmaro-forms'//... building an express appapp.post('/',async(req,res)=>{awaitrosmaro_form_model.handle(req)res.redirect('/')})app.get('/',async(req,res)=>{//you probably want to add the whole html skeleton as wellres.send(awaitrender_model(rosmaro_form_model,req.csrfToken()))})