- Practice using JavaScript templates for a simple blog
- Practice modularizing code and templates
- Practice separating view and logic concerns
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!
-
Create a template with an id of
page-template
that will represent the page of a blog post, including asidebar
element and apost
element that will hold our blog post. -
Create a
post-template
that will represent the blog post itself. It should have aheader
for the post title and afooter
for the post author, and be wrapped in anarticle
element. -
Create a
comments-template
that will be the container for the collection of comments on the blog post, as well as the comment form. -
Create a
comment-template
that will hold an individual comment. Should have afooter
for the commenter name. -
Provide a form with an id of
post-form
to 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-template
to 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.