A metal chair A metal chair - 4 years ago 149
HTML Question

Rendering to html file with express and bodyparser

I have a form where a user submits login data using express. It takes the input the user writes into a username field. I want to take that input and display it in the head of existing html document.

Is there anyway I can access individual elements of an html document using node or express in order to append this information to it?

I have an existing html document and I'd like to be able to render it on that page without having to have my entire html page as a variable. So if I have an html document with a body of:

<body> placeholder </body>

Is it possible for me to render the user information where the placeholder text is currently rendered?

Answer Source

If I understand the question correctly, you are looking for a way to render an HTML page based on some runtime value provided by the user.

You can do so using a template middleware like jade or ejs

In that way you could say in your HTML

<body><%= username %></body>

and provide a username when rendering the HTML page.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download