Last active
May 24, 2023 12:44
-
-
Save arfaram/1fbb40faa1995de26fc1dd3a374817b1 to your computer and use it in GitHub Desktop.
Ibexa Icons
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;
//...
$dir = './bundles/ibexaicons/img/icons/';
$finder = new Finder();
$finder->files()->in($dir);
/** @var SplFileInfo $file */
foreach ($finder as $file) {
$svgs[$file->getBasename('.svg')] = $file->getContents();
}
return $this->render(
'default.html.twig',
[
'svgs' => $svgs
]
);
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
{% for file,svg in svgs %}
<div class="col-md-2">
<div class="well">
<div>
{{ svg|raw }}
</div>
{{ file }}
</div>
</div>
{% if loop.index is divisible by(5) and not loop.last %}
</div>
<div class="row">
{% endif %}
{% endfor %}
<div>
<style>
svg{
width:50px;height: 50px
}
.col-md-2{text-align: center}
</style>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment