-
Notifications
You must be signed in to change notification settings - Fork 0
/
AssetManifestTags.php
executable file
·52 lines (42 loc) · 1.04 KB
/
AssetManifestTags.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Statamic\Addons\AssetManifest;
use Statamic\Extend\Tags;
class AssetManifestTags extends Tags
{
use AssetManifestTrait;
/**
* The {{ asset_manifest }} tag - outputs the revision manifest file as JSON.
*
* @return string
*/
public function index()
{
return $this->getManifest()->toJson();
}
/**
* The {{ asset_manifest:css }} tag - outputs the URL or tag for the theme's main CSS file.
*
* @return string
*/
public function css()
{
$url = $this->getAssetPath('css');
if ($this->getBool('tag')) {
return '<link rel="stylesheet" href="' . $url . '" />';
}
return $url;
}
/**
* The {{ asset_manifest:js }} tag - outputs the URL or tag for the theme's main JS file.
*
* @return string
*/
public function js()
{
$url = $this->getAssetPath('js');
if ($this->getBool('tag')) {
return '<script src="' . $url . '"></script>';
}
return $url;
}
}