Skip to content

Commit

Permalink
updating to work the way you'd expect it to work with in-code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
watchwood committed Jun 29, 2017
1 parent e0f0acc commit d922062
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/BladeStrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ protected static function trim($param) {

public static function panel($expression) {
$params = static::getParams($expression);
$title = static::trim($params[0]);
$class = isset($params[1]) ? "panel-".static::trim($params[1]) : "panel-default";
$title = trim($params[0]);
$class = isset($params[1]) ? "'panel-".static::trim($params[1])."'" : "'panel-default'";

$html = "<div class='panel {$class}'>";
$html = "<div class='panel <?={$class}?>'>";
if ($title) {
$html .= "<div class='panel-heading'><h3 class='panel-title'>{$title}</h3></div>";
$html .= "<div class='panel-heading'><h3 class='panel-title'><?={$title}?></h3></div>";
}
$html .= "<div class='panel-body'>";

Expand All @@ -37,11 +37,11 @@ public static function endPanel($expression) {

public static function alert($expression) {
$params = static::getParams($expression);
$title = static::trim($params[0]);
$class = isset($params[1]) ? "alert-".static::trim($params[1]) : "alert-info";
$title = trim($params[0]);
$class = isset($params[1]) ? "'alert-".static::trim($params[1])."'" : "'alert-info'";


$html = "<div class='alert {$class}'>";
$html = "<div class='alert <?={$class}?>'>";
if ($title) {
$html .= "<h5>{$title}</h5>";
}
Expand Down
12 changes: 6 additions & 6 deletions tests/BladeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class BladeTest extends TestCase
public function testPanel(){
//default panel
$string = BladeStrap::panel("");
$this->assertEquals("<div class='panel panel-default'><div class='panel-body'>", $string);
$this->assertEquals("<div class='panel <?='panel-default'?>'><div class='panel-body'>", $string);

//string titles get passed to result
$string = BladeStrap::panel("'Test Title'");
$this->assertContains(">Test Title<", $string);
$this->assertContains("Test Title", $string);

//variable titles get passed to result
$string = BladeStrap::panel('$title');
$this->assertContains('>$title<', $string);
$this->assertContains('$title', $string);

//custom panel types titles
$string = BladeStrap::panel('($title, "primary")');
Expand All @@ -37,15 +37,15 @@ public function testEndPanel(){
public function testAlert(){
//default
$string = BladeStrap::alert("");
$this->assertEquals("<div class='alert alert-info'>", $string);
$this->assertEquals("<div class='alert <?='alert-info'?>'>", $string);

//string titles get passed to result
$string = BladeStrap::alert("'Test Title'");
$this->assertContains(">Test Title<", $string);
$this->assertContains("Test Title", $string);

//variable titles get passed to result
$string = BladeStrap::alert('$title');
$this->assertContains('>$title<', $string);
$this->assertContains('$title', $string);

//custom alert types titles
$string = BladeStrap::alert('($title, "primary")');
Expand Down

0 comments on commit d922062

Please sign in to comment.