Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/braunstetter/assets-push-bundle
A clean and easy way to extend your assets (css, js) from any point inside of your twig templates.
https://github.com/braunstetter/assets-push-bundle
asset-management assets symfony twig twig-extension twig-templates
Last synced: about 1 month ago
JSON representation
A clean and easy way to extend your assets (css, js) from any point inside of your twig templates.
- Host: GitHub
- URL: https://github.com/braunstetter/assets-push-bundle
- Owner: Braunstetter
- Created: 2021-08-17T11:10:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-03T18:02:04.000Z (about 3 years ago)
- Last Synced: 2024-11-24T16:14:10.980Z (2 months ago)
- Topics: asset-management, assets, symfony, twig, twig-extension, twig-templates
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# AssetsPushBundle
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/braunstetter/assets-push-bundle/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/braunstetter/assets-push-bundle/?branch=main)
[![Build Status](https://app.travis-ci.com/Braunstetter/assets-push-bundle.svg?branch=main)](https://app.travis-ci.com/Braunstetter/assets-push-bundle)
[![Total Downloads](http://poser.pugx.org/braunstetter/assets-push-bundle/downloads)](https://packagist.org/packages/braunstetter/assets-push-bundle)
[![License](http://poser.pugx.org/braunstetter/assets-push-bundle/license)](https://packagist.org/packages/braunstetter/assets-push-bundle)Push your assets from everywhere inside your templates into the ``.
## Installation
`composer require braunstetter/assets-push-bundle`
## Usage
After the installation you can use the two tags from each template to register additional resources.
```html
{% css '/breadcrumbs.css' %}
{% js '/breadcrumbs.js' %}
```After that you are able to query the assets with the `assets()` function.
It will give you an array of assets like that:
```php
[
'css' => [
'/breadcrumbs.css',
'/custom.css',
'/app.css',
],
'js' => [
'/breadcrumbs.js'
],
]
```Now you can use this on top of your pages:
```html
{% block title %}Welcome!{% endblock %}{% block metadata %}{% endblock %}
{% block pushedJs deferred %}
{% for asset in assets()['js'] %}
{% endfor %}
{% endblock %}{% block pushedCSS deferred %}
{% for asset in assets()['css'] %}
{% endfor %}
{% endblock %}```