for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of BraincraftedBootstrapBundle.
*
* (c) 2012-2013 by Florian Eckerstorfer
*/
namespace Braincrafted\Bundle\BootstrapBundle\Twig;
use Twig_Extension;
use Twig_SimpleFunction;
* BootstrapLabelExtension
* @category TwigExtension
* @package BraincraftedBootstrapBundle
* @subpackage Twig
* @author Florian Eckerstorfer <[email protected]>
* @copyright 2012-2013 Florian Eckerstorfer
* @license http://opensource.org/licenses/MIT The MIT License
* @link http://bootstrap.braincrafted.com Bootstrap for Symfony2
class BootstrapBadgeExtension extends Twig_Extension
{
* {@inheritDoc}
public function getFunctions()
return array(
new Twig_SimpleFunction(
'badge',
array($this, 'badgeFunction'),
array('pre_escape' => 'html', 'is_safe' => array('html'))
)
);
}
* Returns the HTML code for a badge.
* @param string $text The text of the badge
* @return string The HTML code of the badge
public function badgeFunction($text)
return sprintf('<span class="badge">%s</span>', $text);
public function getName()
return 'braincrafted_bootstrap_badge';