A
A
Anonymous2015-12-22 23:01:50
JavaScript
Anonymous, 2015-12-22 23:01:50

Symfony 3 how to call bundle components jquery in template?

Installed via composer jquery ( composer require components/jquery )
What is the correct way to call it in the template, in particular for the dev version?

Twig templating engine (of course)
Also worth AsseticManager

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-12-23
@InfernoZ

As always, there are a lot of options.

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

    {% block body %}

        <script>
            {{ source('/absolute/path/') }}
        </script>
        
    {% endblock %}

assetic:
    assets:
        js:
            inputs:
                - '/path/to/libray'
            output: 'output/path'

More details in the doc. symfony.com/doc/current/cookbook/templating/twig_e...
But the "ideal" option would be to use the composer hooks
https://getcomposer.org/doc/articles/scripts.md
(after updating, installing, etc.) )
To do this, create a command linking the data and the composer hook handler itself.
(As a result, linking will be available after operations with composer and in bin/consoe command:name)
Where you simply create a link in "@AppBundle/Resources/public/jquery.js"
But that's not all.
https://github.com/francoispluchino/composer-asset...
(attention to asset-installer-paths)
class Controller 
{
    public function proxyAssetFile($path)
    {
        $realpath = $this->blackMagic($path);
        
        return new \Symfony\Component\HttpFoundation\BinaryFileResponse($realpath);
    }
}

Choose any...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question