To participate you must create an account on apostrophenow.org. If you have already done so, click Login.
Changeset 4464
- Timestamp:
- 01/07/12 14:17:56 (5 months ago)
- Author:
- tboutell
- Message:
-
New 'prepend' option to aAssets::compileLessIfNeeded() and aAssets::cexecute() specifies LESS code to be prepended to the content of the file to be compiled. This is useful for automatically setting LESS variables based on configuration settings. Needed by PR
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r4339
|
r4464
|
|
| 55 | 55 | * be used to retrieve the cached array; if you get an array back $info['compiled'] has |
| 56 | 56 | * the compiled CSS code. |
| | 57 | * |
| | 58 | * If $options['prepend'] is set it is prepended to the LESS code before compilation. |
| 57 | 59 | */ |
| 58 | 60 | static public function compileLessIfNeeded($path, $compiled, $options = array()) |
| … |
… |
|
| 121 | 123 | } |
| 122 | 124 | $lastUpdated = is_array($info) ? $info['updated'] : 0; |
| 123 | | $info = aAssets::cexecute($info, false); |
| | 125 | |
| | 126 | $lessOptions = array(); |
| | 127 | if (isset($options['prepend'])) |
| | 128 | { |
| | 129 | $lessOptions['prepend'] = $options['prepend']; |
| | 130 | } |
| | 131 | $info = aAssets::cexecute($info, false, $lessOptions); |
| 124 | 132 | // Our replacement for cexecute() calls parse() on the contents of a file, so |
| 125 | 133 | // the cache info structure is missing the name of the original requested file. |
| … |
… |
|
| 207 | 215 | * The cache structure is a plain-ol' PHP associative array and can |
| 208 | 216 | * be serialized and unserialized without a hitch. |
| | 217 | * |
| | 218 | * If $options['prepend'] is present that LESS code is prepended before |
| | 219 | * the compilation. |
| 209 | 220 | * |
| 210 | 221 | * @param mixed $in Input |
| 211 | | * @param bool $force Force rebuild? |
| | 222 | * @param bool $force Force rebuild |
| | 223 | * @param array $options |
| 212 | 224 | * @return array lessphp cache structure |
| 213 | 225 | */ |
| 214 | | public static function cexecute($in, $force = false) |
| | 226 | public static function cexecute($in, $force = false, $options = array()) |
| 215 | 227 | { |
| 216 | 228 | // assume no root |
| … |
… |
|
| 246 | 258 | $out = array(); |
| 247 | 259 | $out['root'] = $root; |
| 248 | | $out['compiled'] = $less->parse(file_get_contents($root)); |
| | 260 | $code = file_get_contents($root); |
| | 261 | if (isset($options['prepend'])) |
| | 262 | { |
| | 263 | $code = $options['prepend'] . "\n" . $code; |
| | 264 | } |
| | 265 | $out['compiled'] = $less->parse($code); |
| 249 | 266 | $out['files'] = $less->allParsedFiles(); |
| 250 | 267 | $out['updated'] = time(); |
Download in other formats: