diff --git a/core/core.services.yml b/core/core.services.yml
index 9291712..065fa5e 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -1098,6 +1098,8 @@ services:
   twig.loader.filesystem:
     class: Twig_Loader_Filesystem
     arguments: ['@app.root']
+  template.attachment.manager:
+    class: Drupal\Core\Template\TemplateAttachmentManager
   element_info:
     alias: plugin.manager.element_info
   file.mime_type.guesser:
diff --git a/core/lib/Drupal/Core/Template/TemplateAttachmentManager.php b/core/lib/Drupal/Core/Template/TemplateAttachmentManager.php
new file mode 100644
index 0000000..9091551
--- /dev/null
+++ b/core/lib/Drupal/Core/Template/TemplateAttachmentManager.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Contains \Drupal\Core\Template\TemplateAttachmentManager.
+ */
+
+namespace Drupal\Core\Template;
+
+/**
+ * Manages page attachments.
+ */
+class TemplateAttachmentManager {
+
+  /**
+   * Stores page attachments.
+   *
+   * @var array
+   */
+  protected $attachments;
+
+  /**
+   * Constructs a new TemplateAttachmentManager.
+   */
+  public function __construct() {
+    $this->attachments = array();
+  }
+
+  /**
+   * Gets the page attachments.
+   *
+   * @param string $type
+   *   The attachment type.
+   *
+   * @return array
+   *   The page attachments.
+   */
+  public function getAttachments($type = 'library') {
+    return $this->attachments[$type];
+  }
+
+  /**
+   * Adds page attachments.
+   *
+   * @param mixed $attachments
+   *   An attachment name or an array of attachment names.
+   * @param string $type
+   *   The attachment type.
+   */
+  public function addAttachments($attachments, $type = 'library') {
+    $this->attachments[$type][] = $attachments;
+  }
+}
diff --git a/core/lib/Drupal/Core/Template/TwigExtension.php b/core/lib/Drupal/Core/Template/TwigExtension.php
index 511cefb..23ba81d 100644
--- a/core/lib/Drupal/Core/Template/TwigExtension.php
+++ b/core/lib/Drupal/Core/Template/TwigExtension.php
@@ -76,6 +76,7 @@ public function getFunctions() {
       new \Twig_SimpleFunction('path', array($this, 'getPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
       new \Twig_SimpleFunction('url_from_path', array($this, 'getUrlFromPath'), array('is_safe_callback' => array($this, 'isUrlGenerationSafe'))),
       new \Twig_SimpleFunction('link', array($this, 'getLink')),
+      new \Twig_SimpleFunction('addLib', array($this, 'addLibraries')),
     );
   }
 
@@ -254,4 +255,14 @@ public function isUrlGenerationSafe(\Twig_Node $args_node) {
     return array();
   }
 
+  /**
+   * Adds libraries to the page.
+   *
+   * @param array $libraries
+   *   An array of libraries.
+   */
+  public function addLibraries($libraries = array()) {
+    \Drupal::service('template.attachment.manager')->addAttachments($libraries, 'library');
+  }
+
 }
