Compare commits

...
6 Commits
Author SHA1 Message Date
Adam Engebretson 3a312d39ff Merge pull request #153 from mikemand/patch-1
Use array_get's third parameter for default value.
2016-01-27 16:29:54 -06:00
Micheal Mand fa2628d311 Use array_get's third parameter for default value.
This allows for using boolean values as default options.
2016-01-27 14:49:58 -06:00
Adam Engebretson e5011d337c Merge pull request #151 from antonioribeiro/patch-1
Remove uneeded use.
2016-01-26 18:26:51 -06:00
Antonio Carlos Ribeiro 0e8e2dbc67 Remove uneeded use. 2016-01-26 21:39:03 -02:00
Adam Engebretson 7ec0ca55ca Merge pull request #146 from paulvl/5.2
Function Tag
2016-01-20 12:28:21 -06:00
Paul Vidal 6f35784c8b added function tag 2016-01-20 00:56:22 -05:00
4 changed files with 37 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ trait Componentable
$default = null; $default = null;
} }
$data[$variable] = array_get($arguments, $i) ?: $default; $data[$variable] = array_get($arguments, $i, $default);
$i++; $i++;
} }
-1
View File
@@ -7,7 +7,6 @@ use BadMethodCallException;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\HtmlString; use Illuminate\Support\HtmlString;
use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\Factory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Session\SessionInterface; use Illuminate\Session\SessionInterface;
use Illuminate\Support\Traits\Macroable; use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Routing\UrlGenerator; use Illuminate\Contracts\Routing\UrlGenerator;
+15
View File
@@ -486,6 +486,21 @@ class HtmlBuilder
return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL); return $this->toHtmlString('<meta' . $this->attributes($attributes) . '>' . PHP_EOL);
} }
/**
* Generate an html tag.
*
* @param string $tag
* @param mixed $content
* @param array $attributes
*
* @return \Illuminate\Support\HtmlString
*/
public function tag($tag, $content, array $attributes = [])
{
$content = is_array($content) ? implode(PHP_EOL, $content) : $content;
return $this->toHtmlString('<' . $tag . $this->attributes($attributes) . '>' . PHP_EOL . $this->toHtmlString($content) . PHP_EOL . '</' . $tag . '>' . PHP_EOL);
}
/** /**
* Transform the string to an Html serializable object * Transform the string to an Html serializable object
* *
+21
View File
@@ -46,6 +46,27 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase
$this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">' . PHP_EOL, $result); $this->assertEquals('<meta name="description" content="Lorem ipsum dolor sit amet.">' . PHP_EOL, $result);
} }
public function testTag()
{
$result1 = $this->htmlBuilder->tag('p', 'Lorem ipsum dolor sit amet.');
$result2 = $this->htmlBuilder->tag('p', 'Lorem ipsum dolor sit amet.', ['class' => 'text-center']);
$result3 = $this->htmlBuilder->tag('div', '<p>Lorem ipsum dolor sit amet.</p>', ['class' => 'row']);
$content = [
$this->htmlBuilder->image('http://example.com/image1'),
$this->htmlBuilder->image('http://example.com/image2'),
];
$result4 = $this->htmlBuilder->tag('div', $content, ['class' => 'row']);
$this->assertEquals('<p>' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result1);
$this->assertEquals('<p class="text-center">' . PHP_EOL . 'Lorem ipsum dolor sit amet.' . PHP_EOL . '</p>' . PHP_EOL, $result2);
$this->assertEquals('<div class="row">' . PHP_EOL . '<p>Lorem ipsum dolor sit amet.</p>' . PHP_EOL . '</div>' . PHP_EOL, $result3);
$this->assertEquals('<div class="row">' . PHP_EOL . '<img src="http://example.com/image1">' . PHP_EOL . '<img src="http://example.com/image2">' . PHP_EOL . '</div>' . PHP_EOL, $result4);
}
public function testMetaOpenGraph() public function testMetaOpenGraph()
{ {
$result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']); $result = $this->htmlBuilder->meta(null, 'website', ['property' => 'og:type']);