Skip to content

Commit

Permalink
Update Gist method to use correct URL, and usable in records
Browse files Browse the repository at this point in the history
  • Loading branch information
GwendolenLynch committed Sep 1, 2017
1 parent a92d0be commit f862a00
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/GitHubGistExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ class GitHubGistExtension extends SimpleExtension
*
* @return \Twig_Markup
*/
public function twigGist($gist = null)
public function gistCallback($gist = null)
{
if ($gist === null) {
return new \Twig_Markup('You must provide a gist to embed.', 'UTF-8');
return new \Twig_Markup('You must provide a gist ID to embed.', 'UTF-8');
}

$html = sprintf('<script src="//gist.github.com/%s"></script>', $gist);
$html = sprintf('<script src="https://gist.github.com/%s.js"></script>', $gist);

return new \Twig_Markup($html, 'UTF-8');
}
Expand All @@ -34,7 +33,15 @@ public function twigGist($gist = null)
protected function registerTwigFunctions()
{
return [
'gist', 'twigGist'
'gist' => 'gistCallback',
];
}

/**
* {@inheritdoc}
*/
protected function isSafe()
{
return true;
}
}

0 comments on commit f862a00

Please sign in to comment.