From bc6d9f98ff137ea62bcbfc0ca5e22863d35c5545 Mon Sep 17 00:00:00 2001 From: "Paul (xobb) Chubatyy" Date: Thu, 7 Apr 2016 16:28:04 +0300 Subject: [PATCH] Add ability to link to file on gist Now when the file is passed to the gist filter only that file will be displayed, not the whole gist. Example usage: ```{{ gist("000000000000000000000000", "somefile.php") }}``` Backward compatible by the way. --- system/src/Grav/Common/Twig/TwigExtension.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index fb37f934c..43dac127f 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -623,12 +623,17 @@ class TwigExtension extends \Twig_Extension * Output a Gist * * @param string $id + * @param string $file * * @return string */ - public function gistFunc($id) + public function gistFunc($id, $file = false) { - return ''; + $url = 'https://gist.github.com/' . $id . '.js'; + if ($file) { + $url .= '?file=' . $file; + } + return ''; } /**