emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Spaces in new template engine #208

Closed josejachuf closed 6 years ago

josejachuf commented 6 years ago

Up to W1.2.3 in the template the spaces between the html code and the python code were respected. For example


<a href="{{=url('.url')}}">
     <i class="fa fa-user"></ i> {{= some}}
</a>

but with W1.2.4, the space between </ i> and {{= ...}} disappears when rendered.

gi0baro commented 6 years ago

@josejachuf that's strange. 1.2.4 should be better than 1.2.3 on html preservation.

Anyway, I can't reproduce this. I've just tried in bloggy to add something similar:

{{for post in posts:}}
    <li>
        <h2>{{=post.title}}</h2>
        <a href="{{=url('one', post.id)}}">Read more</a> {{='foo'}}
        <hr />
    </li>
{{pass}}

and this is the page source rendered in browser:

<ul class="posts"><li>
<h2>foo2</h2>
<a href="/post/1">Read more</a> foo<hr />
</li></ul></div>

only the indentation is dropped.

gi0baro commented 6 years ago

@josejachuf anyway, if you can't find out what's going on, you can also change your app configuration

app.config.templates_prettify = True

And this should keep html in the original format. The rendering will be a bit slower in this way.

josejachuf commented 6 years ago

@gi0baro

Weppy 1.2.3 <a href="xxx" class="btn btn-success"><i class="fa fa-user"></i> 1</a>

Weppy 1.2.4 <a href="xxx" class="btn btn-success"<i class="fa fa-user"></i>1</a>

now I will try to change app.config.templates_prettify = True

josejachuf commented 6 years ago

with w1.2.4 and app.config.templates_prettify = True works fine

gi0baro commented 6 years ago

@josejachuf hmm why is the second line missing a bracket?

gi0baro commented 6 years ago

@josejachuf ok, I figured out. There's a typo in one of the last commits. 1.2.5 is on its way!

gi0baro commented 6 years ago

@josejachuf this is fixed both in master and in v1.2.5 You should now be able to have well formatted html even without the prettify option.