I am using a form library for Node.js ( Forms ), which will provide me with a form on the backend as follows:
var signup_form = forms.create({ username: fields.string({required: true}) , password: fields.password({required: true}) , confirm: fields.password({ required: true , validators: [validators.matchField('password')] }) , email: fields.email() }); var signup_form_as_html = signup_form.toHTML();
The final line is var signup_var signup_form_as_html = signup_form.toHTML(); creates an HTML block that looks like this:
<div class="field required"><label for="id_username">Username</label><input type="text" name="username" id="id_username" /></div><div class="field required"><label for="id_password">Password</label><input type="password" name="password" id="id_password" /></div><div class="field required"><label for="id_confirm">Confirm</label><input type="password" name="confirm" id="id_confirm" /></div><div class="field"><label for="id_email">Email</label><input type="text" name="email" id="id_email" /></div>
Basically just a long line of HTML. Then I try to do this using EJS and Express using the following code:
res.render('signup.ejs', { session: loginStatus(req) , form: signup_form_as_html });
But when rendering HTML, it's just the line I posted above, not the actual HTML (and therefore the form I want). Is there a way to make this string render as actual HTML using EJS? Or will I have to use something like Jade?
MrJaeger Apr 26 2018-12-12T00: 00Z
source share