Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created September 27, 2009 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bangpound/194745 to your computer and use it in GitHub Desktop.
Save bangpound/194745 to your computer and use it in GitHub Desktop.
Semantic HTML drupal element
/**
* Implementation of hook_elements().
*/
function semanticviews_elements() {
return array(
'semantic_html' => array(
'#input' => FALSE,
'#html_element' => '',
'#pre_render' => array('semanticviews_html_element_pre_render'),
),
);
}
/**
*
*/
function semanticviews_html_element_pre_render(&$element) {
$element['#type'] = 'markup';
switch (isset($element['#content'])) {
case TRUE:
$element['#prefix'] = '<'. check_plain($element['#html_element']) . drupal_attributes($element['#attributes']) .'>';
$element['#value'] = $element['#content'];
$element['#suffix'] = '</'. check_plain($element['#html_element']) .'>';
break;
case FALSE:
$element['#value'] = '<'. check_plain($element['#html_element']) . drupal_attributes($element['#attributes']) .' />';
break;
}
return $element;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment