Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning Single-page Web Application Development
  • Table Of Contents Toc
Learning Single-page Web Application Development

Learning Single-page Web Application Development

By : Fernando Monteiro
3 (1)
close
close
Learning Single-page Web Application Development

Learning Single-page Web Application Development

3 (1)
By: Fernando Monteiro

Overview of this book

This book is aimed at web developers who are familiar with frontend technologies like JavaScript, HTML, and CSS, and modern tools like Bower, Yeoman, and Grunt.
Table of Contents (10 chapters)
close
close
9
Index

Templates with Embedded JavaScript


At the beginning of the chapter, we adopted the mechanism of templates called EJS, which is very easy to understand. Besides, EJS gives us the template logic functionality within its syntax and can be easily embedded within HTML files. Its use is very similar to that of Handlebars, another excellent JavaScript library to use templates; for example:

<h1><%= title %></h1>
<ul>
  <% for( var i = 0; i < bands.length; i++ ) { %>
    <li>
      <%= bands[i] %>
    </li>
  <% } %>
</ul>

It is very similar to other programming languages such as PHP and RoR.

However, you can use the template that suits you; Node.js has a great list of template engines for all tastes.

Tip

Another good option for a template engine is Swig, which can be installed through the npm command:

npm install swig
  1. Let's create the following files' templates in the views folder:

    • login.ejs

    • profile.ejs

    • signup.ejs

  2. Also, we will create a...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning Single-page Web Application Development
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon