Created
September 27, 2009 12:16
-
-
Save bangpound/194745 to your computer and use it in GitHub Desktop.
Semantic HTML drupal element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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