mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
Convert Zulip to use Jinja2 templates.
This results in a substantial performance improvement for all of
Zulip's backend templates.
Changes in templates:
- Change `block.super` to `super()`.
- Remove `load` tag because Jinja2 doesn't support it.
- Use `minified_js()|safe` instead of `{% minified_js %}`.
- Use `compressed_css()|safe` instead of `{% compressed_css %}`.
- `forloop.first` -> `loop.first`.
- Use `{{ csrf_input }}` instead of `{% csrf_token %}`.
- Use `{# ... #}` instead of `{% comment %}`.
- Use `url()` instead of `{% url %}`.
- Use `_()` instead of `{% trans %}` because in Jinja `trans` is a block tag.
- Use `{% trans %}` instead of `{% blocktrans %}`.
- Use `{% raw %}` instead of `{% verbatim %}`.
Changes in tools:
- Check for `trans` block in `check-templates` instead of `blocktrans`
Changes in backend:
- Create custom `render_to_response` function which takes `request` objects
instead of `RequestContext` object. There are two reasons to do this:
1. `RequestContext` is not compatible with Jinja2
2. `RequestContext` in `render_to_response` is deprecated.
- Add Jinja2 related support files in zproject/jinja2 directory. It
includes a custom backend and a template renderer, compressors for js
and css and Jinja2 environment handler.
- Enable `slugify` and `pluralize` filters in Jinja2 environment.
Fixes #620.
This commit is contained in:
@@ -1,34 +1,33 @@
|
||||
{% extends "zerver/portico_signup.html" %}
|
||||
{% load i18n %}
|
||||
{% comment %}
|
||||
{#
|
||||
Allow the user to accept the terms, creating an email record of that fact.
|
||||
{% endcomment %}
|
||||
#}
|
||||
|
||||
{% block for_you %}for {% if company_name %} {{company_name}} {% else %} __________ {% endif %} {% endblock %}
|
||||
{% block portico_content %}
|
||||
|
||||
<p>({% trans "Welcome! We think you'll like it here" %}.)</p>
|
||||
<p>({{ _("Welcome! We think you'll like it here") }}.)</p>
|
||||
|
||||
|
||||
<div class="pitch">
|
||||
<hr/>
|
||||
<p>{% trans "You're almost there. We just need you to do one last thing" %}.</p>
|
||||
<h3>{% trans "Accept the Zulip terms of service" %}</h3>
|
||||
<p>{{ _("You're almost there. We just need you to do one last thing") }}.</p>
|
||||
<h3>{{ _("Accept the Zulip terms of service") }}</h3>
|
||||
</div>
|
||||
|
||||
<form method="post" class="form-horizontal" id="registration" action="{% url 'zerver.views.accounts_accept_terms' %}">
|
||||
{% csrf_token %}
|
||||
<form method="post" class="form-horizontal" id="registration" action="{{ url('zerver.views.accounts_accept_terms') }}">
|
||||
{{ csrf_input }}
|
||||
<div class="control-group">
|
||||
<label for="id_email" class="control-label">{% trans "Email" %}</label>
|
||||
<label for="id_email" class="control-label">{{ _("Email") }}</label>
|
||||
<div class="controls fakecontrol">
|
||||
<p>{{ email }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="id_full_name" class="control-label">{% trans "Your name" %}</label>
|
||||
<label for="id_full_name" class="control-label">{{ _("Your name") }}</label>
|
||||
<div class="controls">
|
||||
<input id="id_full_name" class="required" type="text" name="full_name"
|
||||
value="{% if form.full_name.value %}{{ form.full_name.value }}{% endif %}"
|
||||
value="{% if form.full_name.value() %}{{ form.full_name.value() }}{% endif %}"
|
||||
maxlength="100" />
|
||||
{% if form.full_name.errors %}
|
||||
{% for error in form.full_name.errors %}
|
||||
@@ -41,17 +40,17 @@ Allow the user to accept the terms, creating an email record of that fact.
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
{% comment %}
|
||||
{#
|
||||
This is somewhat subtle.
|
||||
Checkboxes have a name and value, and when the checkbox is ticked, the form posts
|
||||
with name=value. If the checkbox is unticked, the field just isn't present at all.
|
||||
|
||||
This is distinct from 'checked', which determines whether the checkbox appears
|
||||
at all. (So, it's not symmetric to the code above.)
|
||||
{% endcomment %}
|
||||
#}
|
||||
<input id="id_terms" class="required" type="checkbox" name="terms"
|
||||
{% if form.terms.value %}checked="checked"{% endif %} />
|
||||
{% trans "I agree to the" %} <a href="/terms">{% trans "Terms of Service" %}</a>.
|
||||
{% if form.terms.value() %}checked="checked"{% endif %} />
|
||||
{{ _("I agree to the") }} <a href="/terms">{{ _("Terms of Service") }}</a>.
|
||||
</label>
|
||||
{% if form.terms.errors %}
|
||||
{% for error in form.terms.errors %}
|
||||
|
||||
Reference in New Issue
Block a user