T
T
test2018-07-09 12:41:36
symfony
test, 2018-07-09 12:41:36

How to use javascript in symfony correctly?

I didn’t find a sensible answer to my question anywhere. How to properly include js in symfony. Let’s say I have a base page, and the “equipment” page inherits it. And the question is this. I have js , which is only needed on the equipment page. And it seems logical it only on it and connect it, but I saw a lot where js is connected only in the base template .. Where is the truth?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fishernet, 2018-09-29
@Fishernet

twig:

{% extends 'base.html.twig' %}

...

{% block javascripts %}
    {{ parent() }}
    <script src="{{ asset('build/equipment.js') }}"></script>
{% endblock %}

A
anxieter, 2019-01-06
@anxieter

I also subscribed to this question of the author. In our project, the front-end developer writes code in templates inside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question