Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions classes/Kohana/HTML.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,33 @@ public static function image($file, array $attributes = NULL, $protocol = NULL,

return '<img'.HTML::attributes($attributes).' />';
}

/**
* Creates a svg link.
*
* echo HTML::svg('media/img/logo.svg', array('class' => 'my-class'));
*
* @param string $file file name
* @param array $attributes default attributes
* @return string
*/
public static function svg($file, array $attributes = NULL)
{
$ret = file_get_contents($file);

if ( ! empty($attributes))
{
$dom = new DOMDocument();
$dom->loadXml($ret);

foreach($attributes as $key => $value)
$dom->documentElement->setAttribute($key, $value);

$ret = $dom->saveHTML();
}

return $ret;
}

/**
* Compiles an array of HTML attributes into an attribute string.
Expand Down