diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index b65b71e..d69283d 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -910,6 +910,8 @@ function drupal_find_base_themes($themes, $key, $used_keys = array()) {
  */
 function theme($hook, $variables = array()) {
   static $default_attributes;
+  $render_function = FALSE;
+
   // If called before all modules are loaded, we do not necessarily have a full
   // theme registry to work with, and therefore cannot process the theme
   // request properly. See also _theme_load_registry().
@@ -971,6 +973,10 @@ function theme($hook, $variables = array()) {
     }
   }
 
+  // If an explicit render_function is set, use that one.
+  if (isset($variables['#theme_render_function'])) {
+    $render_function = $variables['#theme_render_function'];
+  }
   // If a renderable array is passed as $variables, then set $variables to
   // the arguments expected by the theme function.
   if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
@@ -1059,7 +1065,11 @@ function theme($hook, $variables = array()) {
 
   // Generate the output using either a function or a template.
   $output = '';
-  if (isset($info['function'])) {
+  // Do we have an explicit render_function passed via #theme_render_function?
+  if (isset($render_function) && is_callable($render_function)) {
+    $output = call_user_func($render_function, $variables);
+  }
+  else if (isset($info['function'])) {
     if (function_exists($info['function'])) {
       $output = $info['function']($variables);
     }
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 9cd17b0..97af346 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -26,6 +26,7 @@ public function getFunctions() {
       'hide' => new TwigReferenceFunction('twig_hide'),
       'render_var' => new TwigReferenceFunction('twig_render_var'),
       'show' => new TwigReferenceFunction('twig_show'),
+      'render_inline_template' => new TwigReferenceFunction('twig_render_inline_template'),
     );
   }
 
@@ -56,6 +57,7 @@ public function getTokenParsers() {
       new TwigFunctionTokenParser('hide'),
       new TwigFunctionTokenParser('show'),
       new TwigTransTokenParser(),
+      new TwigInlineTemplateTokenParser(),
     );
   }
 
diff --git a/core/lib/Drupal/Core/Template/TwigInlineTemplateTokenParser.php b/core/lib/Drupal/Core/Template/TwigInlineTemplateTokenParser.php
new file mode 100644
index 0000000..ec22a89
--- /dev/null
+++ b/core/lib/Drupal/Core/Template/TwigInlineTemplateTokenParser.php
@@ -0,0 +1,79 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Core\Template\TwigInlineTemplateTokenParser.
+ */
+
+namespace Drupal\Core\Template;
+
+/**
+ * A class that defines the Twig 'inline_template' token parser for Drupal.
+ *
+ * The token parser converts a token stream created from template source
+ * code into an Abstract Syntax Tree (AST).  The AST will later be compiled
+ * into PHP code usable for runtime execution of the template.
+ *
+ * @see \Twig_TokenParser
+ */
+class TwigInlineTemplateTokenParser extends \Twig_TokenParser {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function parse(\Twig_Token $token) {
+    $lineno = $token->getLine();
+    $stream = $this->parser->getStream();
+    $expr = $this->parser->getExpressionParser()->parseExpression();
+
+    $stream->expect(\Twig_Token::BLOCK_END_TYPE);
+    $this->parser->pushLocalScope();
+    $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+
+    if ($stream->test(\Twig_Token::NAME_TYPE)) {
+      $value = $stream->next()->getValue();
+
+      if ($value != $name) {
+        throw new \Twig_Error_Syntax(sprintf("Expected endinline_template for inline template for render array '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename());
+      }
+    }
+    $this->parser->popLocalScope();
+    $stream->expect(\Twig_Token::BLOCK_END_TYPE);
+
+    // @todo: parseName instead where $expr above.
+    $name = 'link';
+    $args = array();
+    $args[$name] = new \Twig_Node_Expression_Array(array(), $this->parser->getCurrentToken()->getLine());
+
+    $arguments = new \Twig_Node($args);
+
+    // Create dynamic macro
+    $this->parser->setMacro($name, new \Twig_Node_Macro($name, new \Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
+
+    $arguments = new \Twig_Node_Expression_Array(array(
+      new \Twig_Node_Expression_Name($name, $lineno),
+      new \Twig_Node_Expression_Name('_self', $lineno),
+      new \Twig_Node_Expression_Constant('get'.$name, $lineno)
+    ), $lineno);
+
+    $node = new \Twig_Node_Expression_Function('render_inline_template', $arguments, $lineno);
+    $node = new \Twig_Node_Print($node, $lineno);
+
+    return $node;
+  }
+
+  /**
+   * Detect the end of a 'trans' tag.
+   */
+  public function decideBlockEnd($token) {
+    return $token->test('endinline_template');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getTag() {
+    return 'inline_template';
+  }
+
+}
diff --git a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
index 710faa0..5645d9b 100644
--- a/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
+++ b/core/lib/Drupal/Core/Template/TwigNodeVisitor.php
@@ -72,7 +72,7 @@ function leaveNode(\Twig_NodeInterface $node, \Twig_Environment $env) {
     }
 
     if ($this->isReference) {
-      if ($node instanceof \Twig_Node_Expression_Name) {
+      if ($node instanceof \Twig_Node_Expression_Name && !$node->isSpecial()) {
         $name = $node->getAttribute('name');
         return new TwigNodeExpressionNameReference($name, $node->getLine());
       }
diff --git a/core/themes/engines/twig/twig.engine b/core/themes/engines/twig/twig.engine
index e09ec99..27bde28 100644
--- a/core/themes/engines/twig/twig.engine
+++ b/core/themes/engines/twig/twig.engine
@@ -155,3 +155,19 @@ function twig_show($element) {
   }
   // @todo Add warning in else case
 }
+
+/**
+ * Inline template
+ */
+function twig_render_inline_template($element, $template, $function) {
+  if (!($element instanceof TwigReference)) {
+    return;
+  }
+  $element = &$element->getReference();
+  if (!is_array($element)) {
+    return;
+  }
+
+  $element['#theme_render_function'] = array($template, $function);
+  return $element;
+}
