We are programmers, and therefore, we are lazy. As such, we're going to create a new template at resources/templates/signup.html
and have it extend our base template. This way, all we need to worry about is the content of the actual login form and a heading. This is the beauty of template inheritance:
{% extends "templates/base.html" %} {% block content %} <h1>Sign Up <span class="small">Nobody will ever know.</span></h1> <div class="row"> <div class="col-md-6"> <form role="form"> <div class="form-group"> <label for="username">Username</label> <input type="input" class="form-control" name="username" placeholder="AtticusButch"> </div> <div class="form-group"> <label for="email">Email address</label> <input type="email" class="form-control" name="email" placeholder="[email protected]"> </div> <div class="form-group"> <label for="password">Password</label> <input type="password" class="form-control" name="password" placeholder="security-through-obscurity"> </div> <button type="submit" class="btn btn-default">Submit</button> </form> </div> </div> {% endblock %}
If you save and refresh http://localhost:300/signup
, you'll notice we still see the goofy salutation. That's because we haven't adjusted our sign up route to render the template.
Back in the hipstr.routes.home
namespace, add a new function, signup-page
, which is responsible for rendering the sign up page. We can use the hipstr.layout/render
function to handle it for us:
(defn signup-page [] (layout/render "signup.html"))
Finally, get rid of that goofy salutation in the sign up route and replace it with a call to signup-page
:
(GET "/signup" [] (signup-page))
Now when you save and refresh, you'll see your new form:
3.143.0.85