The Gist
class provides an interface for easily
- Embedding gists
- Caching gists
- Adding the gist's source to
<noscript>
tags in case JS is disabled
<?php
include 'gist.php';
$gist = new Gist('123456', 'some_file.php');
echo $gist->render();
?>
Gist::__construct($gist_id[, $file_name = null[, $cache = true]])
Prepares the class for adding gists to the page
<tr>
<td>$file_name</td>
<td>string (optional)</td>
<td>Which file to display; if empty it will embed all files</td>
</tr>
<tr>
<td>$cache</td>
<td>boolean (optional) (default=true)</td>
<td>Cache the gist source in a file and display it in `<noscript>` tags</td>
</tr>
$gist_id | string | The ID of the gist to add |
Gist::script_tag()
Creates the script tag for embedding gists
<script src="https://gist.github.com/123456.js"></script>
Gist::noscript_tag()
If caching is enabled then download
and display the gist content in
<noscript>
tags
<noscript><pre><code>The source gist</code></pre></noscript>
Create the script and noscript tags in one go
<script src="https://gist.github.com/123456.js"></script>
<noscript><pre><code>The source gist</code></pre></noscript>
Attempt to download a gist and cache it into a file
{null}
Returns the path for where the file should be cached
./gists_cache/58abasdf4858asadf58