I've been thinking about efficently re-rendering Twig template in the browser recently...
Given this template:
<div>{{ variable }}</div>
{% if flag == true %}
<div>{{ variable2 }}</div>
{% endif %}| services: | |
| php: | |
| image: tugboatqa/php:7.2-apache | |
| default: true | |
| depends: mysql | |
| commands: | |
| init: | |
| - docker-php-ext-install opcache | |
| - a2enmod headers rewrite | |
| - wget -O /usr/local/bin/drush |
| #!/usr/bin/env bash | |
| # Use: Create an empty directory and download this file as netlifybug.sh | |
| # Then, run "netlify link", then ./netlifybug.sh. | |
| # Use default deploy path (".") at prompts. | |
| # You should see a failed deploy first, then a successful deploy after. | |
| mkdir -p subdir | |
| touch index.html subdir/index.html | |
| RAND=$(openssl rand -base64 12) |
| <?php | |
| /** | |
| * Implements hook_metatags_attachments_alter(). | |
| * | |
| * This function allows you to define fallback tokens in case a field is empty. | |
| * | |
| * If all fallback values are empty, the tag will be empty. | |
| * | |
| * Example: [node:field_image:medium]||[node:field_legacy_image:medium]||/fallback.png |
| <?php | |
| /** | |
| * @file | |
| * Allows Node to make command line requests without a web server. | |
| * | |
| * Example use with Node to POST content: | |
| * const { spawnSync } = require('child_process'); | |
| * const input = JSON.stringify({ path: '/some/path', content: 'request content' }); | |
| * spawnSync(drush, ['php:script', 'request.php', '--script-path=some/script/path'], { input: input }); |
| <?php | |
| // Download to Drupal root (where index.php is) and run "drush scr dump.php" | |
| $storage = \Drupal::entityTypeManager()->getStorage('node'); | |
| $nodes = $storage->loadMultiple(); | |
| echo 'Processing ' . count($nodes) . ' nodes...' . "\n"; |
| <?php | |
| use Drupal\Component\Graph; | |
| function chunk_graph(Graph $graph_object) { | |
| // Sort the graph by weight. | |
| $graph = $graph_object->searchAndSort(); | |
| uasort($graph, 'Drupal\Component\Utility\SortArray::sortByWeightElement'); | |
| // Ensure that graph nodes are sorted from least to most edges. | |
| $graph = array_reverse($graph); |
| <?php | |
| use Symfony\Component\Process\Process; | |
| // The total sleep time of this queue is 22, but it only takes ~10 seconds to | |
| // run as new commands are started as soon as another finishes and the | |
| // $concurrency limit is not met. | |
| $command_queue = [ | |
| 'sleep 1', | |
| 'sleep 1', |
| # This script attempts to create a patch file that includes all security fixes | |
| # between two tags. | |
| # Hypothetically, you could just apply the patch to your Drupal site after the | |
| # script is finished successfully to be up to date. | |
| # Biggest successful D7 patch - 7.36 => 7.58 | |
| # Biggest successful D8 patch - 8.4.0 => 8.4.7 / 8.6.0 => 8.6.7 | |
| # WARNING: This is an experimental patch generation method and may not be | |
| # perfect. If you use this on production I take no responsibility for your |
I've been thinking about efficently re-rendering Twig template in the browser recently...
Given this template:
<div>{{ variable }}</div>
{% if flag == true %}
<div>{{ variable2 }}</div>
{% endif %}| <?php | |
| $libraries = ['core/jquery']; | |
| // In this example I'm just concerned about JS assets, but you can use other | |
| // services to render other assets. | |
| /** @var \Drupal\Core\Asset\AssetResolver $asset_resolver */ | |
| $asset_resolver = \Drupal::service('asset.resolver'); | |
| /** @var \Drupal\Core\Asset\JsCollectionRenderer $js_renderer */ |