forked from jsbin/jsbin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sprocketize.php
35 lines (29 loc) · 871 Bytes
/
sprocketize.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
<?php
require_once('config.php');
require_once('lib/sprockets/sprocket.php');
// get path from request
$filePath = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
// prepare sprocket
$sprocket = new Sprocket($filePath, array(
'contentType' => 'application/x-javascript',
'baseUri' => '../js',
'baseFolder' => '/js',
'assetFolder' => '..',
'debugMode' => OFFLINE ? true : false,
'autoRender' => false
));
// change base folder based on extension
switch ($sprocket->fileExt)
{
case 'css':
$sprocket->setContentType('text/css')->setBaseFolder('/css');
break;
default: case 'js':
$sprocket->setBaseFolder(array('./js/vendor', './js/vendor/codemirror'));
break;
}
// having to hack the source path to get it work properly.
$sprocket->filePath = '.' . str_replace(VERSION . '/', '', $sprocket->filePath);
// tada!
$sprocket->render();
?>