Added SpeakerDeckExtension
This commit is contained in:
parent
3cb4e74448
commit
ad6a00b003
9 changed files with 49 additions and 7 deletions
38
src/AppBundle/Twig/SpeakerDeckExtension.php
Normal file
38
src/AppBundle/Twig/SpeakerDeckExtension.php
Normal 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';
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,8 @@
|
|||
services:
|
||||
app.twig.speakerdeck:
|
||||
class: AppBundle\Twig\SpeakerDeckExtension
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
app.twig.vimeo:
|
||||
class: AppBundle\Twig\VimeoExtension
|
||||
tags:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue