mirror of https://github.com/zulip/zulip.git
templates: Abstract render_bundle behind a Jinja2 macro.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
parent
1df5cdc41a
commit
9b38bcc2a6
|
@ -70,8 +70,8 @@ needs to be accessible from one of the entry points defined in
|
|||
`app` and `common` bundles.
|
||||
* If it's just used on a single standalone page (e.g. `/stats`),
|
||||
create a new entry point in `tools/webpack.assets.json`. Use the
|
||||
`render_bundle` function in the relevant Jinja2 template to inject
|
||||
the compiled JS and CSS.
|
||||
`bundle` macro (defined in `templates/zerver/base.html`) in the
|
||||
relevant Jinja2 template to inject the compiled JS and CSS.
|
||||
|
||||
If you want to test minified files in development, look for the
|
||||
`DEBUG =` line in `zproject/settings.py` and set it to `False`.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('activity') }}
|
||||
{{ bundle('activity') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -7,14 +7,14 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block customhead %}
|
||||
{{ render_bundle('portico') }}
|
||||
{{ bundle('portico') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="app portico-page">
|
||||
|
||||
{{ render_bundle('translations') }}
|
||||
{{ render_bundle('stats') }}
|
||||
{{ bundle('translations') }}
|
||||
{{ bundle('stats') }}
|
||||
|
||||
<div class="page-content">
|
||||
<div id="id_stats_errors" class="alert alert-error"></div>
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('activity') }}
|
||||
{{ render_bundle('support') }}
|
||||
{{ bundle('activity') }}
|
||||
{{ bundle('support') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('confirm-preregistrationuser') }}
|
||||
{{ bundle('confirm-preregistrationuser') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ render_bundle('billing') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{{ bundle('billing') }}
|
||||
<script src="https://checkout.stripe.com/checkout.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
{% include 'zerver/billing_nav.html' %}
|
||||
|
||||
{{ render_bundle('translations') }}
|
||||
{{ bundle('translations') }}
|
||||
<div class="portico-landing billing-upgrade-page">
|
||||
<div class="hero small-hero"></div>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ render_bundle('upgrade') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{{ bundle('upgrade') }}
|
||||
<script src="https://checkout.stripe.com/checkout.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
{% include 'zerver/billing_nav.html' %}
|
||||
|
||||
{{ render_bundle('translations') }}
|
||||
{{ bundle('translations') }}
|
||||
|
||||
<div class="portico-landing billing-upgrade-page">
|
||||
<div class="hero small-hero"></div>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block commonjs %}
|
||||
{{ render_bundle('app', attrs='nonce="%s"' % (csp_nonce,)) }}
|
||||
{{ render_bundle('katex', attrs='nonce="%s"' % (csp_nonce,)) }}
|
||||
{{ bundle('app') }}
|
||||
{{ bundle('katex') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block customhead %}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<style media="screen">
|
||||
.app.portico-page { padding-bottom: 0px; }
|
||||
</style>
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
}
|
||||
</style>
|
||||
|
||||
{{ render_bundle('translations', attrs='nonce="%s"' % (csp_nonce,)) }}
|
||||
{{ render_bundle('katex', attrs='nonce="%s"' % (csp_nonce,)) }}
|
||||
{{ render_bundle('portico') }}
|
||||
{{ render_bundle('archive') }}
|
||||
{{ render_bundle('archive-styles') }}
|
||||
{{ bundle('translations') }}
|
||||
{{ bundle('katex') }}
|
||||
{{ bundle('portico') }}
|
||||
{{ bundle('archive') }}
|
||||
{{ bundle('archive-styles') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -26,11 +26,16 @@
|
|||
var page_params = {debug_mode: false};
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% macro bundle(name) %}
|
||||
{{ render_bundle(name, attrs='nonce="%s"' % (csp_nonce,) if csp_nonce else '') }}
|
||||
{% endmacro %}
|
||||
|
||||
<!-- This is a temporary block to enable webpack transition
|
||||
This allows pages requiring common files via webpack to override
|
||||
this block -->
|
||||
{% block commonjs %}
|
||||
{{ render_bundle('common', attrs='nonce="%s"' % (csp_nonce,)) }}
|
||||
{{ bundle('common') }}
|
||||
{% endblock %}
|
||||
{% block customhead %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{# Login page. #}
|
||||
{% block portico_content %}
|
||||
{{ render_bundle('dev-login') }}
|
||||
{{ bundle('dev-login') }}
|
||||
<!-- The following empty tag has unique data-page-id so that this
|
||||
page can be easily identified in it's respective JavaScript file -->
|
||||
<div data-page-id="dev-login"></div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "zerver/base.html" %}
|
||||
|
||||
{% block porticocustomhead %}
|
||||
{{ render_bundle('portico') }}
|
||||
{{ bundle('portico') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -28,5 +28,5 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{ render_bundle("help") }}
|
||||
{{ bundle("help") }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% extends "zerver/base.html" %}
|
||||
{% block content %}
|
||||
{{ render_bundle('email-log') }}
|
||||
{{ bundle('email-log') }}
|
||||
<div class="container">
|
||||
<div style="position: fixed">
|
||||
<div class="alert">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
{% set OPEN_GRAPH_DESCRIPTION = 'First class threading on top of everything you could want from real-time chat.' %}
|
||||
|
||||
{% block customhead %}
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<!-- Bootstrap 2.3.2-->
|
||||
<script src="https://stackpath.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
<style>
|
||||
.portico-page {
|
||||
padding-bottom: 0px;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
{% block customhead %}
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('integrations-dev-panel') }}
|
||||
{{ render_bundle('portico') }}
|
||||
{{ bundle('integrations-dev-panel') }}
|
||||
{{ bundle('portico') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('integrations') }}
|
||||
{{ bundle('integrations') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block hello_page_container %} hello-main{% endblock %}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('signup') }}
|
||||
{{ bundle('signup') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
#}
|
||||
|
||||
{% block porticocustomhead %}
|
||||
{{ render_bundle('translations') }}
|
||||
{{ render_bundle('portico') }}
|
||||
{{ bundle('translations') }}
|
||||
{{ bundle('portico') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
@ -4,5 +4,5 @@
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('signup') }}
|
||||
{{ bundle('signup') }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ Form is validated both client-side using jquery-validate (see signup.js) and ser
|
|||
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('zxcvbn') }}
|
||||
{{ render_bundle('translations') }}
|
||||
{{ bundle('zxcvbn') }}
|
||||
{{ bundle('translations') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "zerver/portico_signup.html" %}
|
||||
{% block customhead %}
|
||||
{{ super() }}
|
||||
{{ render_bundle('zxcvbn') }}
|
||||
{{ bundle('zxcvbn') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<script>
|
||||
var contributors_list = {{ contrib|safe }};
|
||||
</script>
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
{% endblock %}
|
||||
|
||||
{% block portico_content %}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
{% block customhead %}
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
{{ render_bundle('landing-page') }}
|
||||
{{ bundle('landing-page') }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -336,6 +336,7 @@ def is_django_block_tag(tag):
|
|||
'for',
|
||||
'if',
|
||||
'ifequal',
|
||||
'macro',
|
||||
'verbatim',
|
||||
'blocktrans',
|
||||
'trans',
|
||||
|
|
Loading…
Reference in New Issue