[eluser]stormbytes[/eluser]
I cleaned it up a bit, validated input, and added conditional spaces to make the finished tag look a bit cleaner.
With a custom Textmate command (bundles) this rocks
Code:
// Function modified to accept tag attributes!
function heading( $data = 'Heading Text', $h = '1', $attribs = '' ) {
$data = ( !strlen( $data ) == 0 ) ? $data : "Heading Text";
$attribs = ( !strlen( $attribs ) == 0 ) ? " " . $attribs . " " : "";
$heading = "<h" . $h . $attribs . ">" . $data . "</h" . $h . ">";
return $heading;
}
Textmate Bundle Command
Code:
heading('${1:heading-text}', '${2:1}', '${3: ${4:id="${5:css-id}" }${6:class="${7:css-class}"}}');${0}
Anyone using Textmate (who has extended the 'heading()' html helper as described in this thread) can easily apply the code above to create a new textmate (bundle) command. I simply duplicated the existing 'heading' command (CodeIgniter 1.72 bundle) and applied the code above to the body of the command. Add a tab-trigger of 'heading' and this will allow you to individually tab through each of the elements of the heading tag/function.