HTML and CSS Reference
In-Depth Information
attempting to edit HTML and CSS inside your JavaScript application logic. You need to be
able to mix static content with the results of the application logic, and you'll look at that in
the next section.
E.1.3. Serving mixed static and dynamic content with Node
In this section you're going to create an HTML template file with placeholders that will be
replaced with dynamic values when the page is requested.
Step 1: Create a static template with placeholders
The index.html template is shown in the next listing. It's identical to the previous in-
dex.html file, apart from the added placeholder for the dynamic variable. Create a new
working directory and place this index.html file into it.
Listing E.5. A simple template index.html
Step 2: Mix dynamic content into your template
The following listing inserts dynamic values into a static template file using the standard
JavaScript String.Replace function. Create an app.js file in your working directory
and add this code to it.
Search WWH ::

Custom Search