diff --git a/core/includes/common.inc b/core/includes/common.inc index e2a28c3..37336d6 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1912,10 +1912,14 @@ function drupal_http_header_attributes(array $attributes = array()) { * internal to the site, $options['language'] is used to determine whether * the link is "active", or pointing to the current page (the language as * well as the path must match). This element is also used by url(). + * - 'render': A boolean value indicating whether the the function should + * return a rendered string (TRUE) or a structured array for rendering later + * (FALSE). Defaults to TRUE. * - Additional $options elements used by the url() function. * - * @return string - * An HTML string containing a link to the given path. + * @return mixed + * Either an HTML string containing a link to the given path or an array for + * containing the structure of the element for rendering later. * * @see url() * @see theme_link() @@ -1935,6 +1939,7 @@ function l($text, $path, array $options = array()) { 'query' => array(), 'html' => FALSE, 'language' => NULL, + 'render' => TRUE, ); // Because l() is called very often we statically cache values that require an @@ -1988,6 +1993,15 @@ function l($text, $path, array $options = array()) { // Sanitize the link text if necessary. $text = $variables['options']['html'] ? $variables['text'] : check_plain($variables['text']); + // Return an array if render is FALSE. + if ($variables['options']['render'] === FALSE) { + return array( + 'path' => $url, + 'attributes' => $attributes, + 'text' => $text, + ); + } + return '' . $text . ''; }