Nov

29

Flat, But Smart

I just wanted to note something neat.

When I was setting up my flatpage template last night I realized I could run template filters on the two strings, flatpage,title and flatpage.content. So now, instead of having to embed raw HTML in my flatpage entry like a brutish savage, I can enter pure, clean-burning markdown and just pipe it through the parser in the template.

Here's the flatpages/default.html template:

{% extends "base.html" %}
 
{% load markup %}
 
{% block title %}{{ block.super }} - {{ flatpage.title }}{% endblock %}
 
{% block content %}
<h1>{{ flatpage.title }}</h1>
{{ flatpage.content|markdown }}
{% endblock %}

Funny side note: I actually felt shamed into editing this template to conform to Eric Holscher's Gentleman's Agreemant on Django Templates