@@ -3,11 +3,10 @@ Lightweight asset loader for CodeIgniter 4
33
44## Quick Start
55
6- 1 . Run : ` > composer require tatter/assets `
6+ 1 . Install with Composer : ` > composer require tatter/assets `
772 . Put CSS & JS files in: public/assets
8- 3 . Load the helper: ` helper("tatter\assets"); `
9- 3 . Add in head tag: ` echo css(); `
10- 4 . Add to footer: ` echo js(); `
8+ 3 . Add in head tag: ` <?= service('assets')->display('css') ?> `
9+ 4 . Add to footer: ` <?= service('assets')->display('js') ?> `
1110
1211## Features
1312
@@ -17,7 +16,7 @@ Provides out-of-the-box asset loading for CSS and JavaScript files for CodeIgnit
1716
1817Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities
1918and always be up-to-date:
20- ` > composer require tatter/assets `
19+ * ` > composer require tatter/assets `
2120
2221Or, install manually by downloading the source files and copying them into CodeIgniter 4's
2322app/ same subdirectories.
@@ -30,30 +29,30 @@ comments. If no config file is found the library will use its defaults.
3029
3130## Usage
3231
33- If installed correctly CodeIgniter 4 will detect and autoload the library, helper, and
34- (optional) config. Initialize the helper before using its functions:
35- ` helper("tatter\assets"); `
36-
37- Then call the helper functions ` css() ` and ` js() ` to retrieve the appropriate assets.
32+ If installed correctly CodeIgniter 4 will detect and autoload the library, service, and
33+ config. Use the service ` display() ` method to retrieve the appropriate assets:
34+ ` <?= service('assets')->display('css') ?> `
3835
3936## Structure
4037
4138The library searches the assets directory (default: public/assets) for files matching the
4239current route, loading them in a cascading fashion for each route segment.
40+
4341** Example:** https://example.com/users/view/12
4442
4543The library will first load any root assets (public/assets/* .css * .js), then assets in
46- the users subfolder (public/assets/users/) then view subfolder, then 12 subfolder. Any
44+ the ' users' subfolder (public/assets/users/), then ' view' subfolder, then '12' subfolder. Any
4745missing or invalid folders are ignored.
4846
4947Additional assets may be loaded from the config variable $routes - this is particularly
5048helpful for including pre-bundled libraries.
49+
5150** Example:**
5251```
5352public $routes = [
54- "" => ["bootstrap/dist/css/bootstrap.min.css", "bootstrap/dist/js/bootstrap.bundle.min.js"]
53+ '' => ["bootstrap/dist/css/bootstrap.min.css", "bootstrap/dist/js/bootstrap.bundle.min.js"]
5554];
5655```
5756
58- This tells the library to load Bootstrap for every route ("" ) without having to move it
57+ This tells the library to load Bootstrap for every route ('' ) without having to move it
5958from its pre-bundled subdirectory.
0 commit comments