/
CssAsset.cfc
79 lines (70 loc) · 1.9 KB
/
CssAsset.cfc
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Represents a css asset.
*/
component implements="Asset" accessors="true" {
/**
* The filepath to the css asset.
*/
property name="filepath";
/**
* The priority of the css asset. Defaults to 0.
*/
property name="priority" type="numeric" default="0";
/**
* Constructs a new css asset pointing to the given filepath.
*
* @filepath The filepath to the css asset.
*
* @returns The newly created css asset.
*/
public Asset function init( required string filepath ) {
variables.filepath = arguments.filepath;
return this;
}
/**
* Renders the asset's contents to a string.
*
* @returns The rendered asset.
*/
public string function toString() {
return '<link type="text/css" rel="stylesheet" href="#variables.filepath#">';
}
/**
* Returns the priority of the asset.
*
* @returns The asset's priority.
*/
public numeric function getPriority() {
return variables.priority;
}
/**
* Sets the priority of the asset.
*
* @priority The priority value to set.
*
* @returns The asset instance.
*/
public Asset function setPriority( required numeric priority ) {
variables.priority = arguments.priority;
return this;
}
/**
* Returns the type of the asset.
*
* @returns The asset type.
*/
public string function getType() {
return "css";
}
/**
* Returns true if this asset is considered the same as the otherAsset.
*
* @otherAsset The other asset to test against this one for sameness.
*
* @returns True, if this asset is considered the same as the otherAsset.
*/
public boolean function isSameAs( required any otherAsset ) {
return isInstanceOf( otherAsset, "CssAsset" ) &&
( variables.filepath == otherAsset.getFilepath() );
}
}