X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fdocs%2Fplugins%2FPrerender.md;fp=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fdocs%2Fplugins%2FPrerender.md;h=5e8e31130726abf125e778f533194eeb3b8574d0;hp=f4db9731d40efde48bc250e77f72401036af8969;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/themes/contrib/bootstrap/docs/plugins/Prerender.md b/web/themes/contrib/bootstrap/docs/plugins/Prerender.md index f4db9731d..5e8e31130 100644 --- a/web/themes/contrib/bootstrap/docs/plugins/Prerender.md +++ b/web/themes/contrib/bootstrap/docs/plugins/Prerender.md @@ -1,4 +1,4 @@ - + # @BootstrapPrerender @@ -16,14 +16,18 @@ example will only work if the link is passed some sort of `#context` when the render array is built, like the following: ```php + 'link', '#title' => t('Download'), - '#url' => \Drupal\Core\Url::fromUserInput('/download', ['query' => ['item' => '1234']]), + '#url' => Url::fromUserInput('/download', [ + 'query' => ['item' => '1234'], + ]), '#context' => [ 'downloadButton' => TRUE, ], ]; +?> ``` Replace all following instances of `THEMENAME` with the actual machine name of @@ -33,15 +37,11 @@ Create a file at `./THEMENAME/src/Plugin/Prerender/Link.php` with the following contents: ```php -/** - * @file - * Contains \Drupal\THEMENAME\Plugin\Prerender\Link. - */ +getProperty('context', []); - // Make downloadButton links into buttons. // Same as above, just a little cleaner with the Element utility class. - if (!empty($context['downloadButton'])) { + if ($element->getContext('downloadButton')) { $element->addClass(['btn', 'btn-primary', 'btn-lg'])->setIcon(Bootstrap::glyphicon('download-alt')); } @@ -102,7 +102,7 @@ class Link extends \Drupal\bootstrap\Plugin\Prerender\Link { } } - +?> ``` ## Rebuild the cache {#rebuild} @@ -115,4 +115,5 @@ To rebuild your cache, navigate to `admin/config/development/performance` and click the `Clear all caches` button. Or if you prefer, run `drush cr` from the command line. -Voilà! After this, you should have a fully functional `@BootstrapPrerender` plugin! +Voilà! After this, you should have a fully functional `@BootstrapPrerender` +plugin!