Skip to content

Instantly share code, notes, and snippets.

@frostbitten
Created March 26, 2016 16:28
Show Gist options
  • Save frostbitten/6db3fcf5309d3349e954 to your computer and use it in GitHub Desktop.
Save frostbitten/6db3fcf5309d3349e954 to your computer and use it in GitHub Desktop.
UserFrosting - Stolz Assets Plugin
{
"name": "userfrosting-plugin-stolz-asssets",
"type": "project",
"description": "Integrates Stolz's Assets Manager",
"license" : "MIT",
"require-dev": {
},
"require": {
"stolz/assets" : "*",
}
}
<?php
namespace UserFrosting;
$app->assets = new \Stolz\Assets\Manager;
$app->assets->config([
'css_dir' => '/css',
'js_dir' => '/js'
]);
$twig = $app->view()->getEnvironment();
$twig->addGlobal( "assets", $app->assets );
// register collections, similar to a 'page-group'
$app->assets->registerCollection("sapphire-theme", [
"my-sapphire-theme.css",
"my-sapphire-scripts.js",
]);
?>
{# these statements must come first #}
{% do assets.add('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.2/css/bootstrap.min.css') %}
{% do assets.add('https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js') %}
{% do assets.add('my-local-styles.css') %}
{% do assets.add('my-app.js') %}
{% do assets.add('sapphire-theme') %} {# a colection #}
{# printing the <script or <link tags #}
{# Change {'pipline' : true } for a single, concatenated file #}
{{ assets.config({'pipeline' : false}).css() | raw }}
{{ assets.config({'pipeline' : false}).js() | raw }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment