-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
namespace Packaged\Dispatch\Assets; | ||
|
||
class LessAsset extends AbstractDispatchableAsset | ||
{ | ||
public function getExtension() | ||
{ | ||
return 'less'; | ||
} | ||
|
||
public function getContentType() | ||
{ | ||
return "text/css"; | ||
} | ||
|
||
public function getContent() | ||
{ | ||
$less = new \lessc; | ||
return $less->compile(parent::getContent()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
class LessAssetTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testMinify() | ||
{ | ||
$original = '@base: 24px; | ||
@border-color: #B2B; | ||
.underline { border-bottom: 1px solid green } | ||
#header { | ||
color: black; | ||
border: 1px solid @border-color + #222222; | ||
.navigation { | ||
font-size: @base / 2; | ||
a { | ||
.underline; | ||
} | ||
} | ||
.logo { | ||
width: 300px; | ||
:hover { text-decoration: none } | ||
} | ||
} | ||
'; | ||
|
||
$expect = '.underline { | ||
border-bottom: 1px solid green; | ||
} | ||
#header { | ||
color: black; | ||
border: 1px solid #dd44dd; | ||
} | ||
#header .navigation { | ||
font-size: 12px; | ||
} | ||
#header .navigation a { | ||
border-bottom: 1px solid green; | ||
} | ||
#header .logo { | ||
width: 300px; | ||
} | ||
#header .logo :hover { | ||
text-decoration: none; | ||
} | ||
'; | ||
|
||
$asset = new \Packaged\Dispatch\Assets\LessAsset(); | ||
|
||
$asset->setContent($original); | ||
$this->assertEquals($expect, $asset->getContent()); | ||
} | ||
|
||
public function testAsset() | ||
{ | ||
$asset = new \Packaged\Dispatch\Assets\LessAsset(); | ||
$this->assertEquals('less', $asset->getExtension()); | ||
$this->assertEquals('text/css', $asset->getContentType()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@base: 24px; | ||
@border-color: #B2B; | ||
|
||
.underline { border-bottom: 1px solid green } | ||
|
||
#header { | ||
color: black; | ||
border: 1px solid @border-color + #222222; | ||
|
||
.navigation { | ||
font-size: @base / 2; | ||
a { | ||
.underline; | ||
} | ||
} | ||
.logo { | ||
width: 300px; | ||
:hover { text-decoration: none } | ||
} | ||
} |