stencilproject / Stencil

Stencil is a simple and powerful template language for Swift.
https://stencil.fuller.li
BSD 2-Clause "Simplified" License
2.34k stars 224 forks source link

Windows newlines breaks the template engine? #296

Open Sweeper777 opened 4 years ago

Sweeper777 commented 4 years ago

I have this code (note the windows new lines \r\n in index):

let base = """
Hello World
{% block content %}
This is base
{% endblock %}
"""
let index = "{% extends \"base.stencil\" %}\r\n{% block content %}\r\nThis is Index\r\n{% endblock %}"
let env = Environment(loader: DictionaryLoader(templates: ["base.stencil": base, "index.stencil": index]))
do {
    print(try env.renderTemplate(name: "index.stencil"))
} catch {
    print(error)
}

This prints:

Hello World

This is base

As if everything after the first line of index got ignored. I know it's weird to have windows new lines on macOS, but I don't think the behaviour of the template engine should depend on what kind of newlines I use, right?