Skip to content

Commit 6871e6f

Browse files
committed
Update usage info for 2.0
1 parent eca727b commit 6871e6f

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

Assets.php.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class Assets extends \Tatter\Assets\Config\Assets
2323

2424
// additional assets to load per route - no leading/trailing slashes
2525
public $routes = [
26-
"" => [
26+
'' => [
2727
"bootstrap/dist/css/bootstrap.min.css",
2828
"bootstrap/dist/js/bootstrap.bundle.min.js",
2929
],
30-
"upload" => [
30+
'files/upload' => [
3131
"dropzone/dropzone.min.css",
3232
"dropzone/dropzone.min.js",
3333
],

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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`
77
2. 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

1817
Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities
1918
and always be up-to-date:
20-
`> composer require tatter/assets`
19+
* `> composer require tatter/assets`
2120

2221
Or, install manually by downloading the source files and copying them into CodeIgniter 4's
2322
app/ 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

4138
The library searches the assets directory (default: public/assets) for files matching the
4239
current route, loading them in a cascading fashion for each route segment.
40+
4341
**Example:** https://example.com/users/view/12
4442

4543
The 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
4745
missing or invalid folders are ignored.
4846

4947
Additional assets may be loaded from the config variable $routes - this is particularly
5048
helpful for including pre-bundled libraries.
49+
5150
**Example:**
5251
```
5352
public $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
5958
from its pre-bundled subdirectory.

0 commit comments

Comments
 (0)