eltharin/twigfilesgetter
最新稳定版本:V1.1.3
Composer 安装命令:
composer require eltharin/twigfilesgetter
包简介
twigfilesgetter Bundle for symfony
README 文档
README
Installation
- Require the bundle with composer:
composer require eltharin/twigfilesgetter
What is TwigFilesGetter Bundle?
This bundle will help you to include css and js files once in your template.
Per example, when you make a Custom FormType who need a script, you can put in the buildView function the lines :
use Eltharin\TwigFilesGetterBundle\Service\FileManager; ... public function buildView(FormView $view, FormInterface $form, array $options) { FileManager::registerJsFile('/bundles/eltharinreloadablefield/js/reloader.js'); ... }
or in a twig template :
{% do addJs('/bundles/eltharinreloadablefield/js/reloader.js') %}
or
{% do addCss('fichier.css') %}
or with a group :
{% do addJs('fichier.js', 'group Name') %}
and in your template :
{{ get_required_js_files() }}
will write
<script src="/bundles/eltharinreloadablefield/js/scripts.js"/></script>
if you want have js in head and after the page you can specify a 'group'
public function buildView(FormView $view, FormInterface $form, array $options)
{
FileManager::registerJsFile('/bundles/eltharinreloadablefield/js/file_in_head.js', 'head');
FileManager::registerJsFile('/bundles/eltharinreloadablefield/js/file_bottom.js', 'bottom');
...
}
and in your template :
in head :
{{ get_required_js_files('head') }}
and
{{ get_required_js_files('bottom') }}
统计信息
- 总下载量: 157
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0
- 更新时间: 2022-08-14