Commit 360c0c07 authored by alexpott's avatar alexpott

Issue #1898444 by jenlampton, Cottser, lbainbridge, duellj, joelpittet, scor:...

Issue #1898444 by jenlampton, Cottser, lbainbridge, duellj, joelpittet, scor: Rdf.module - Convert theme_ functions to Twig.
parent 35d043d5
......@@ -244,6 +244,7 @@ function rdf_theme() {
return array(
'rdf_metadata' => array(
'variables' => array('metadata' => array()),
'template' => 'rdf-metadata',
),
);
}
......@@ -543,27 +544,24 @@ function rdf_preprocess_image(&$variables) {
}
/**
* Returns HTML for a series of empty spans for exporting RDF metadata in RDFa.
* Prepares variables for RDF metadata templates.
*
* Default template: rdf-metadata.html.twig.
*
* Sometimes it is useful to export data which is not semantically present in
* the HTML output. For example, a hierarchy of comments is visible for a human
* but not for machines because this hiearchy is not present in the DOM tree.
* but not for machines because this hierarchy is not present in the DOM tree.
* We can express it in RDFa via empty <span> tags. These aren't visible and
* give machines extra information about the content and its structure.
*
* @param $variables
* @param array $variables
* An associative array containing:
* - metadata: An array of attribute arrays. Each item in the array
* corresponds to its own set of attributes, and therefore, needs its own
* element.
*
* @see rdf_process()
* @ingroup themeable
* @ingroup rdf
*/
function theme_rdf_metadata($variables) {
$output = '';
foreach ($variables['metadata'] as $attributes) {
function template_preprocess_rdf_metadata(&$variables) {
foreach ($variables['metadata'] as $key => $attributes) {
// Add a class so that developers viewing the HTML source can see why there
// are empty <span> tags in the document. The class can also be used to set
// a CSS display:none rule in a theme where empty spans affect display.
......@@ -572,7 +570,6 @@ function theme_rdf_metadata($variables) {
// be used, but for maximum browser compatibility, W3C recommends the
// former when serving pages using the text/html media type, see
// http://www.w3.org/TR/xhtml1/#C_3.
$output .= '<span' . new Attribute($attributes) . '></span>';
$variables['metadata'][$key] = new Attribute($attributes);
}
return $output;
}
{#
/**
* @file
* Default theme implementation for empty spans with RDF attributes.
*
* Available variables:
* - metadata: Each item within corresponds to its own set of attributes,
* and therefore, needs its own 'attributes' element.
*
* @see template_preprocess_rdf_metadata()
*
* @ingroup themeable
*/
#}
{% for attributes in metadata %}
<span{{ attributes }}></span>
{% endfor %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment