S
S
Sergey Burduzha2019-05-09 00:38:10
Pug
Sergey Burduzha, 2019-05-09 00:38:10

Why are scripts not displayed correctly in the pug template?

I have a start template template.pug

body
    block content

      //- block main-nav

    script(src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js")
    block scripts
    script(src="assets/js/main.min.js")

Next, there is the index.pug page, which is inherited from this template.
block content
  include ../includes/mixins
  .hidden
    include ../../../build/assets/i/svg/inline/sprite.svg

  include ../includes/header

  include ../includes/banner
  include ../includes/popular-categories
  include ../includes/advantages
  include ../includes/promo
  include ../includes/discount
  include ../includes/sales-liders
  include ../includes/you-see
  include ../includes/questions
  include ../includes/footer
  include ../includes/popups/consultation
  include ../includes/popups/upgrade

  include ../includes/scripts/ie-scripts

  block scripts
    script(src="assets/libs/jquery-easy-scroll/jquery.easeScroll.js")
    script(src="assets/libs/slick/slick/slick.min.js")
    script(src="assets/libs/simplebar/dist/simplebar.min.js")
    script(src="assets/libs/Magnific-Popup/dist/jquery.magnific-popup.min.js")
    script(src="assets/libs/jquery-validation-1.19.0/dist/jquery.validate.min.js")
    script(src="https://api-maps.yandex.ru/2.1/?lang=ru_RU")

So, on the final index.html page, the following is displayed
<script src="assets/libs/jquery-easy-scroll/jquery.easeScroll.js"></script>
    <script src="assets/libs/slick/slick/slick.min.js"></script>
    <script src="assets/libs/simplebar/dist/simplebar.min.js"></script>
    <script src="assets/libs/Magnific-Popup/dist/jquery.magnific-popup.min.js"></script>
    <script src="assets/libs/jquery-validation-1.19.0/dist/jquery.validate.min.js"></script>
    <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <script src="assets/libs/jquery-easy-scroll/jquery.easeScroll.js"></script>
    <script src="assets/libs/slick/slick/slick.min.js"></script>
    <script src="assets/libs/simplebar/dist/simplebar.min.js"></script>
    <script src="assets/libs/Magnific-Popup/dist/jquery.magnific-popup.min.js"></script>
    <script src="assets/libs/jquery-validation-1.19.0/dist/jquery.validate.min.js"></script>
    <script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU"></script>
    <script src="assets/js/main.min.js"></script>
  </body>
</html>

For reasons unknown to me, the scripts block is duplicated, but there is no jquery at the very beginning of the block, which causes an error in the console.
How can you explain this behaviour?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
arsenty, 2019-05-09
@serii81

In index.pug, the Scripts block is inside the Content block, so it is first rendered as the content of the Content block, then separately as Scripts.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question