stencilproject / Stencil

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

Errors logs improvements #167

Closed ilyapuchka closed 6 years ago

ilyapuchka commented 6 years ago

Original PR #146

Example error logs:

1:9: error: 'for' statements should use the following syntax 'for x in y where condition'.
Hello {% for name in %}{{ name }}, {% endfor %}!
         ^~~~~~~~~~~
invalid-base.html2:24: error: filter error
{% block body %}Body {{ target|unknown }} {% endblock %}
                        ^~~~~~~~~~~~~~

invalid-child-super.html2:25: error: filter error
{% block body %}Child {{ block.super }}{% endblock %}
                         ^~~~~~~~~~~
ilyapuchka commented 6 years ago

@kylef I've simplified this a lot by storing filenames and token positions at parsing time instead of calculating them at rendering time, now it looks much closer to what you've started in #82 .

ilyapuchka commented 6 years ago

@kylef this started to fail on swift 3.1 with some creepy compiler error. Maybe we should just drop it already?

DivineDominion commented 6 years ago

Whoa this looks cool. I'd like to +1 here so somebody from the team takes a look :)

djbe commented 6 years ago

@ilyapuchka Any idea how hard it'd be to rebase/rework this on master for you? While this may not seem a "flashy" issue with fancy new features, it could end up being the most useful PR of all those that are open right now for template writers.

ilyapuchka commented 6 years ago

@djbe I've updated this with the latest master. If you are going to merge any PRs please merge this first.

djbe commented 6 years ago

Seeing as you'd rather merge this first, I'll review this one before the others.

ilyapuchka commented 6 years ago

@djbe fixed indentations

ilyapuchka commented 6 years ago

@kylef this is probably a leftover from when I was using it to render error in inheritance nodes. Not needed now, removed in 92ebfe5

ilyapuchka commented 6 years ago

@kylef you'd like to add something?

djbe commented 6 years ago

Seeing as there's no more feedback, and this PR is GTM for me, we can go on to the next PRs 🎉