我想要做的是添加scripts
块dropdown.swig
添加到scripts
中的template.swig
块。
我的使用模式可能是错误的。我有一个使用ejs-locals
模板引擎的工作代码,但我想切换到swig
。
以下是代码:
<!-- template.swig, to be extended -->
<body>
<header>
{% include "navbar.swig" %}
</header>
<!-- template scripts -->
<script src="/scripts/jquery.min.js"></script>
{% block body %}{% endblock %}
<!-- child scripts -->
{% block scripts %}{% endblock %}
</body>
<!-- index.swig, to be rendered-->
{% extends "template.swig" %}
{% block content %}
<div class="container row-fluid">
body
</div> <!-- row-fluid -->
{% endblock %}
<!-- navbar.swig, to be included-->
<div class="navbar navbar-fixed-top">
<!-- bootstrap navbar stuff -->
<!-- ... -->
{% if not hideDropDown %}
{% include "dropdown.swig" %}
{% endif %}
</div>
<!-- dropdown.swig, to be included-->
<div class="btn-group pull-right">
<!-- bootstrap drop down menu stuff -->
<!-- ... -->
</div>
{% block scripts %}
{% autoescape false %}
<script src="/scripts/bootstrap-dropdown.js"></script>
<script>
$(document).ready(function() {
$('.dropdown-toggle').dropdown();
});
</script>
{% endautoescape %}
{% endblock %}