colinta / StrangeCase

It's yet another static site generator. Have you seen jekyll? hyde? Yup. Like those.
http://colinta.com/projects/StrangeCase.html
Other
49 stars 7 forks source link

Lines from top of file removed when using jinja2 extends #34

Closed garyvdm closed 11 years ago

garyvdm commented 12 years ago

Given the following site:

layouts/layout.j2 :

<!doctype html>
<html>
    <head>
      <title>{{ title }}<title>
    <head>
    <body>
    {%- block content %}
    {%- endblock %}    
    </body>
</html>

site/index.j2 :


---
title: Home
top_nav: True
top_nav_sort: 0

---
{%- extends "layouts/layout.j2" %}
{%- block content %}
hello world
{%- endblock %}

The result is:

public/index.html:

    <body>
hello world    
    </body>
</html>

But I expect:

public/index.html:

<!doctype html>
<html>
    <head>
      <title>Home<title>
    <head>
    <body>
hello world    
    </body>
</html>

I traced the issue strange_case.support.jinja.[StrangeCaseTemplate|YamlFrontMatterLoader]

I'm going to have a go at fixing it my self.

colinta commented 12 years ago

Tricky one, that. The problem is the {%- extends tag - specifically the minus that consumes the white space after the front matter, which affects how the front matter is detected. The triple ---s are expected to be on their own line.