Skip to content

Instantly share code, notes, and snippets.


Danny Englander danny-englander

View GitHub Profile
miloskroulik /
Last active May 29, 2021
How to setup xdebug + Lando + PHPstorm when using Drupal 8 recipe

I assume you're using Drupal 8 recipe and Linux as a host OS. Also, xdebug 3.x is assumed, which is standard for Lando-provided PHP image.

Set up Lando

Example .lando.yml file can look like this:

name: xdebug-test
recipe: drupal8
 webroot: web
vkechagias / hook.theme.php
Created Oct 21, 2019
Drupal 8 get page title from route and set this to page_title block
View hook.theme.php
function HOOK_preprocess_block__page_title_block(&$variables) {
$request = \Drupal::request();
$route_match = \Drupal::routeMatch();
$page_title = \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
if (!empty($page_title) && empty($variables['content']['#title'])) {
$variables['content']['#title'] = $page_title;
thejimbirch / metatag_example.php
Created Aug 19, 2019 — forked from mortenson/metatag_example.php
OR statements in metatags...
View metatag_example.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
leymannx / gulpfile.js
Last active Jul 27, 2021
Gulp 4 Sass BrowserSync Kickstart Example
View gulpfile.js
// Requires Gulp v4.
// $ npm uninstall --global gulp gulp-cli
// $ rm /usr/local/share/man/man1/gulp.1
// $ npm install --global gulp-cli
// $ npm install
const { src, dest, watch, series, parallel } = require('gulp');
const browsersync = require('browser-sync').create();
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
thamas / field--field-unit-plural.html.twig
Last active Dec 11, 2018
Drupal 8 Twig: hide a (paragraph) field based on the value of a sibling field
View field--field-unit-plural.html.twig
This snippet is from a component based (Emulsify / Pattern Lab) custom Drupal theme.
The "span_…" variables are the properties of the BEM Twig function.
The goal is to set the default display correctly (when the page loads).
After that the field visibility is manipulated by JS based on user interaction.
{% set amount = element['#object'].field_amount.value %}
iamrobert / tiny-slider-app.js
Created Oct 3, 2018
Tiny Slider - with video stop
View tiny-slider-app.js
app.pageSliders = {
slider: null,
container: ".tiny-slider",
init: function() {
// no reason to continue init if no slider on page
if (!document.querySelector("#mainslider")) {
app.pageSliders.slider = tns({
shadcn /
Created Jul 2, 2018
Value module: |pick and |rename_keys example

Value module: |pick and |rename_keys example

Given the following component:

<div class="card">
  <div class="card-header">
    <h4>{{ title }}</h4>
  <div class="card-body">
illepic /
Last active May 18, 2022
Particle from scratch with all dependencies
#!/usr/bin/env bash
# 1. Skip steps if you already have the tools listed
# 2. Run source ~/.bashrc or source ~/.zshrc after each step to ensure command is registered
# Install Homebrew, if not installed
/usr/bin/ruby -e "$(curl -fsSL"
# Update Homebrew installed packages
brew update && brew upgrade
jeromecoupe / webstoemp-gulpfile.js
Last active Jul 15, 2022
Gulp 4 sample gulpfile.js. For a full explanation, have a look at
View webstoemp-gulpfile.js
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");

Styleguide Throwdown - Part 1



Large goals of style guide:

"Platform agnostic enough” (to be useful to other teams) To make our development process easier Developers report that the current SG2 approach is not furthering those goals. In particular, there are complaints about having to do double work, and the fragility of our build and deploy process.