diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 4cec15b..5a73640 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -132,11 +132,10 @@ public function getFilters() {
// be used in "trans" tags.
// @see TwigNodeTrans::compileString()
new \Twig_SimpleFilter('passthrough', 'twig_raw_filter', array('is_safe' => array('html'))),
- new \Twig_SimpleFilter('placeholder', 'twig_raw_filter', array('is_safe' => array('html'))),
+ new \Twig_SimpleFilter('placeholder', [$this, 'escapePlaceholder'], array('is_safe' => array('html'), 'needs_environment' => TRUE)),
// Replace twig's escape filter with our own.
new \Twig_SimpleFilter('drupal_escape', [$this, 'escapeFilter'], array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
- new \Twig_SimpleFilter('drupal_escape_placeholder', [$this, 'escapePlaceholder'], array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
// Implements safe joining.
// @todo Make that the default for |join? Upstream issue:
@@ -356,21 +355,14 @@ public function attachLibrary($library) {
*
* @param \Twig_Environment $env
* A Twig_Environment instance.
- * @param mixed $arg
+ * @param mixed $string
* The value to be escaped.
- * @param string $strategy
- * The escaping strategy. Defaults to 'html'.
- * @param string $charset
- * The charset.
- * @param bool $autoescape
- * Whether the function is called by the auto-escaping feature (TRUE) or by
- * the developer (FALSE).
*
* @return string|null
* The escaped, rendered output, or NULL if there is no valid output.
*/
- public function escapePlaceholder(\Twig_Environment $env, $arg, $strategy = 'html', $charset = NULL, $autoescape = FALSE) {
- return '' . $this->escapeFilter($env, $arg, $strategy, $charset, $autoescape) . '';
+ public function escapePlaceholder($env, $string) {
+ return '' . $this->escapeFilter($env, $string) . '';
}
/**
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 585013f..a08ec2d 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -19,19 +19,9 @@
class TwigNodeVisitor implements \Twig_NodeVisitorInterface {
/**
- * Defines whether we are in a trans node.
- *
- * @var bool
- */
- protected $inTransNode = FALSE;
-
- /**
* {@inheritdoc}
*/
function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
- if ($node instanceof TwigNodeTrans) {
- $this->inTransNode = TRUE;
- }
return $node;
}
@@ -39,10 +29,6 @@ function enterNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
* {@inheritdoc}
*/
function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
- if ($node instanceof TwigNodeTrans) {
- $this->inTransNode = FALSE;
- }
-
// We use this to inject a call to render_var -> TwigExtension->renderVar()
// before anything is printed.
if ($node instanceof \Twig_Node_Print) {
@@ -61,13 +47,6 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
// Change the 'escape' filter to our own 'drupal_escape' filter.
else if ($node instanceof \Twig_Node_Expression_Filter) {
$name = $node->getNode('filter')->getAttribute('value');
- if (!$this->inTransNode && 'placeholder' === $name) {
- // Use our own escape filter that is SafeMarkup aware.
- $node->getNode('filter')->setAttribute('value', 'drupal_escape_placeholder');
-
- // Store that we have a filter active already that knows how to deal with render arrays.
- $this->skipRenderVarFunction = TRUE;
- }
if ('escape' == $name || 'e' == $name) {
// Use our own escape filter that is SafeMarkup aware.
$node->getNode('filter')->setAttribute('value', 'drupal_escape');