我想要做的是将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 %}