Template Engines Lab
Objectives
Practice using JavaScript templates for a simple blog
Practice modularizing code and templates
Practice separating view and logic concerns
Introduction
In this lab, we're going to be using lodash templates to create a simple blog site with posts and comments. We want to use templates to modularize the page and dynamically load new elements.
Don't forget to run the tests and make sure everything works!
Instructions
Create a template with an id of
page-templatethat will represent the page of a blog post, including asidebarelement and apostelement that will hold our blog post.Create a
post-templatethat will represent the blog post itself. It should have aheaderfor the post title and afooterfor the post author, and be wrapped in anarticleelement.Create a
comments-templatethat will be the container for the collection of comments on the blog post, as well as the comment form.Create a
comment-templatethat will hold an individual comment. Should have afooterfor the commenter name.Provide a form with an id of
post-formto create a blog post with a title, body, and author. Submitting the form should build the page template with the post inside. Make the form submit using acreatePost()function.Provide a form within the
comments-templateto post comments, including commenter name and comment text. These should use the template to insert individual comments into the comments section. You should be able to keep adding more comments. Make the form submit use apostComment()function.
Resources
Clone : https://github.com/learn-co-curriculum/js-templates-template-engines-lab
Last updated