Skip to content

Commit

Permalink
Add Orchestra\Html\HtmlBuilder::attributable().
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <[email protected]>
  • Loading branch information
crynobone committed Sep 13, 2015
1 parent 31e4e7a commit 68dfedc
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/HtmlBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ public function raw($value)
return new Expression($value);
}

/**
* Build a list of HTML attributes from one or two array and generate
* HTML attributes.
*
* @param array $attributes
* @param array $defaults
*
* @return string
*/
public function attributable(array $attributes, array $defaults = [])
{
return $this->attributes($this->decorate($attributes, $defaults));
}

/**
* Build a list of HTML attributes from one or two array.
*
Expand Down Expand Up @@ -88,8 +102,8 @@ protected function buildClassDecorate(array $attributes, array $defaults = [])
{
// Special consideration to class, where we need to merge both string
// from $attributes and $defaults, then take union of both.
$default = Arr::get($defaults, 'class', '');
$attribute = Arr::get($attributes, 'class', '');
$default = isset($defaults['class'] ? $defaults['class'] : '';
$attribute = isset($attributes['class'] ? $attributes['class'] : '';

$classes = explode(' ', trim($default.' '.$attribute));
$current = array_unique($classes);
Expand Down

0 comments on commit 68dfedc

Please sign in to comment.