Rendering the results
We'll be using Selmer to render the Recently Added albums. We'll then display the rendered results instead of the crazy raw JSON.
Selmer templates, to refresh your memory, are stored in the resources/templates
directory. As you may have guessed by now, I appreciate a nicely organized tree structure. So instead of throwing the recently-added
template in with the rest of our templates, we'll create a new albums
directory and house our album-related templates there:
Create a new directory,
albums
, inresources/templates
.Create a new Selmer template for our recently added albums,
resource/templates/albums/recently-added.html
, with the following content:{% extends "templates/base.html" %} <!-- 1 --> {% block content %} <!-- 2 --> <h1>Recently Added</h1> <ol class="albums"> {% for a in albums %} <!-- 3 --> <li> <div class="artist"><a href="/albums/{{a.artist}}">...