In the Views
folder you create the views for your application.
These views can relate to:
By default this framework is using Twig templates, which are located in the templates
folder.
To load assets in your Twig template you have to edit the /container/singleton/view.php
file. Here you can register all the assets (css/javascript) to
be loaded into your Twig template. See sample below:
$namedPackages = [
'jquery' => new UrlPackage('https://code.jquery.com', $versionStrategy),
'bootstrap' => new UrlPackage('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7', $versionStrategy),
'fontawesome' => new UrlPackage('https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0', $versionStrategy),
'css' => new PathPackage('assets/css', $versionStrategy),
'js' => new PathPackage('assets/js', $versionStrategy),
];
As you can see, all the assets get an id
that can be used in your Twig template in the following way:
{% block stylesheet %}
<link href="{{ asset('css/font-awesome.min.css', 'fontawesome') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap.min.css', 'bootstrap') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('css/bootstrap-theme.min.css', 'bootstrap') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('style.css', 'css') }}" rel="stylesheet" />
{% endblock %}
{% block javascript %}
<script src="{{ asset('jquery-3.2.1.min.js', 'jquery') }}" type="text/javascript"></script>
<script src="{{ asset('js/bootstrap.min.js', 'bootstrap') }}" type="text/javascript"></script>
{% endblock %}
In the $namedPackages
you define the paths to the assets, and in the Twig template you define the files you would like to load. The id of the package is used as second
parameter to get the path to this file.
Remote assets are defined by using UrlPackage
.
Local assets are defined by using PathPackage
.