Added SpeakerDeckExtension

This commit is contained in:
Oliver Davies 2016-03-29 09:51:41 +01:00
parent 3cb4e74448
commit ad6a00b003
9 changed files with 49 additions and 7 deletions

View file

@ -0,0 +1,38 @@
<?php
namespace AppBundle\Twig;
use Twig_Extension;
use Twig_SimpleFunction;
class SpeakerDeckExtension extends Twig_Extension
{
/**
* {@inheritdoc}
*/
public function getFunctions()
{
return [
new Twig_SimpleFunction('speakerdeck', [$this, 'embedCode']),
];
}
public function embedCode($dataId, $dataRatio)
{
// <script async class="speakerdeck-embed" data-id="0041804e52664d12a8e31cd118264813" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>
return sprintf(
'<script async class="speakerdeck-embed" data-id="%s" data-ratio="%s" src="//speakerdeck.com/assets/embed.js"></script>',
$dataId,
$dataRatio
);
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'speakerdeck';
}
}