Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -5,7 +5,9 @@
* Handles integration of Twig templates with the Drupal theme system.
*/
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Render\SafeString;
use Drupal\Core\Extension\Extension;
/**
@ -44,7 +46,7 @@ function twig_init(Extension $theme) {
* @param array $variables
* A keyed array of variables that will appear in the output.
*
* @return string
* @return string|\Drupal\Component\Utility\SafeStringInterface
* The output generated by the template, plus any debug information.
*/
function twig_render_template($template_file, array $variables) {
@ -74,7 +76,7 @@ function twig_render_template($template_file, array $variables) {
}
if ($twig_service->isDebug()) {
$output['debug_prefix'] .= "\n\n<!-- THEME DEBUG -->";
$output['debug_prefix'] .= "\n<!-- THEME HOOK: '" . SafeMarkup::checkPlain($variables['theme_hook_original']) . "' -->";
$output['debug_prefix'] .= "\n<!-- THEME HOOK: '" . Html::escape($variables['theme_hook_original']) . "' -->";
// If there are theme suggestions, reverse the array so more specific
// suggestions are shown first.
if (!empty($variables['theme_hook_suggestions'])) {
@ -108,12 +110,13 @@ function twig_render_template($template_file, array $variables) {
$prefix = ($template == $current_template) ? 'x' : '*';
$suggestion = $prefix . ' ' . $template;
}
$output['debug_info'] .= "\n<!-- FILE NAME SUGGESTIONS:\n " . SafeMarkup::checkPlain(implode("\n ", $suggestions)) . "\n-->";
$output['debug_info'] .= "\n<!-- FILE NAME SUGGESTIONS:\n " . Html::escape(implode("\n ", $suggestions)) . "\n-->";
}
$output['debug_info'] .= "\n<!-- BEGIN OUTPUT from '" . SafeMarkup::checkPlain($template_file) . "' -->\n";
$output['debug_suffix'] .= "\n<!-- END OUTPUT from '" . SafeMarkup::checkPlain($template_file) . "' -->\n\n";
$output['debug_info'] .= "\n<!-- BEGIN OUTPUT from '" . Html::escape($template_file) . "' -->\n";
$output['debug_suffix'] .= "\n<!-- END OUTPUT from '" . Html::escape($template_file) . "' -->\n\n";
}
return SafeMarkup::set(implode('', $output));
// This output has already been rendered and is therefore considered safe.
return SafeString::create(implode('', $output));
}
/**
@ -148,29 +151,3 @@ function twig_without($element) {
}
return $filtered_element;
}
/**
* Overrides twig_join_filter().
*
* Safely joins several strings together.
*
* @param array|Traversable $value
* The pieces to join.
* @param string $glue
* The delimiter with which to join the string. Defaults to an empty string.
* This value is expected to be safe for output and user provided data should
* never be used as a glue.
*
* @return \Drupal\Component\Utility\SafeMarkup|string
* The imploded string, which is now also marked as safe.
*/
function twig_drupal_join_filter($value, $glue = '') {
$separator = '';
$output = '';
foreach ($value as $item) {
$output .= $separator . SafeMarkup::escape($item);
$separator = $glue;
}
return SafeMarkup::set($output);
}