I've just made a module that helps with validation and rendering of your forms (https://github.com/shaoner/torti), it can be extended and used with express. Any feedback is welcome!
There is also https://github.com/freewil/express-form Le mercredi 7 janvier 2015 11:18:57 UTC+1, Peter Morris a écrit : > > I created the following plugin.... > > exports = module.exports = function (req, res, next) { > var body = req.body; > if (typeof body === 'undefined') { > return next(new Error('form-values must be used after > body-parser')); > } > var bodyKeys = Object.keys(req.body); > res.locals.fv = function (name, defaultValue) { > if (bodyKeys.indexOf(name) === -1) { > if (typeof defaultValue === 'undefined') { > return ''; > } else { > return defaultValue; > } > } else { > return req.body[name]; > } > } > return next(); > }; > > Then to use it > var formValues = require('./lib/form-values'); > app.use(formValues); > > In the view > input(name="username", value="#{fv('username')}", type="text") > > You can also use #fv('fieldName', 32) > > > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/d512dbe8-60c4-4150-8cc3-56b800545a20%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
