This repository was archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to get function to use attributes in Drupal
- Loading branch information
Evan Willhite
committed
Jul 11, 2017
1 parent
541c97d
commit eb683e7
Showing
18 changed files
with
107 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,5 @@ pattern-lab | |
# NPM | ||
node_modules | ||
npm-debug.log | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Add "t" filter for Pattern Lab. | ||
* | ||
* Bring Drupal filters in just so Pattern Lab doesn't bork. | ||
*/ | ||
|
||
if (!class_exists('Drupal')) { | ||
$filter = new Twig_SimpleFilter('t', function ($string, $array = array()) { | ||
if (is_string($string) && is_array($array)) { | ||
$haystack = $string; | ||
foreach ($array as $needle => $replace) { | ||
$haystack = str_replace($needle, $replace, $haystack); | ||
} | ||
return $haystack; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Add "bem" function for Pattern Lab & Drupal | ||
*/ | ||
|
||
$function = new Twig_SimpleFunction('bem', function ($base_class, $modifiers = array(), $blockname = '') { | ||
$classes = array(); | ||
// If using a blockname to override default class. | ||
if ($blockname) { | ||
// Set blockname class. | ||
$classes[] = $blockname . '__' . $base_class; | ||
// Set blockname--modifier classes for each modifier. | ||
if (isset($modifiers) && is_array($modifiers)) { | ||
foreach ($modifiers as $modifier) { | ||
$classes[] = $blockname . '__' . $base_class . '--' . $modifier; | ||
}; | ||
} | ||
} | ||
// If not overriding base class. | ||
else { | ||
// Set base class. | ||
$classes[] = $base_class; | ||
// Set base--modifier class for each modifier | ||
if (isset($modifiers) && is_array($modifiers)) { | ||
foreach ($modifiers as $modifier) { | ||
$classes[] = $base_class . '--' . $modifier; | ||
}; | ||
} | ||
} | ||
|
||
if (class_exists('Drupal')) { | ||
$classLoader = new ClassLoader(); | ||
$classLoader.loadClass("Attribute"); | ||
$attributes = new Attribute(); | ||
$attributes['class'][] = $classes; | ||
} | ||
else { | ||
$classString = implode(' ', $classes); | ||
$classesSafe = ' class="' . $classString . '"'; | ||
return $classesSafe; | ||
} | ||
|
||
}); |
19 changes: 0 additions & 19 deletions
19
components/_twig-components/functions/blockname.function.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Add "kint" function for Pattern Lab. | ||
*/ | ||
|
||
if (!class_exists('Drupal')) { | ||
$function = new Twig_SimpleFunction('kint', function ($string) { | ||
return $string; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Add "link" function for Pattern Lab. | ||
*/ | ||
|
||
if (!class_exists('Drupal')) { | ||
$function = new Twig_SimpleFunction('link', function ($string) { | ||
return $string; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters