html writer: Difference between revisions
From MoodleDocs
sam marshall (talk | contribs) Created page with "Moodle has a class called html_writer which allows you to output basic HTML tags. This is typically used within renderer functions (or by naughty people in scripts which are outp..." |
sam marshall (talk | contribs) mNo edit summary |
||
| Line 2: | Line 2: | ||
There is no documentation for most of this class. Please look at the source code. | There is no documentation for most of this class. Please look at the source code. | ||
== div, span methods == | |||
{{Moodle 2.5}} | {{Moodle 2.5}} | ||
To allow shorter code when outputting the div and span tags with classes, <code>div</code> and <code>span</code> methods were added in Moodle 2.5. | To allow shorter code when outputting the div and span tags with classes, <code>div</code> and <code>span</code> methods were added in Moodle 2.5. | ||
Revision as of 12:09, 5 March 2013
Moodle has a class called html_writer which allows you to output basic HTML tags. This is typically used within renderer functions (or by naughty people in scripts which are outputting content without using a renderer).
There is no documentation for most of this class. Please look at the source code.
div, span methods
Moodle 2.5
To allow shorter code when outputting the div and span tags with classes, div and span methods were added in Moodle 2.5.
Example usage:
$out .= html_writer::div('anonymous');
$out .= html_writer::div('kermit', 'frog');
$out .= html_writer::start_span('zombie') . 'BRAINS' . html_writer::end_span();
$out .= html_writer::div('Mr', 'toad', array('id' => 'tophat');
This will result in the following HTML from each line:
anonymous
kermit
BRAINS
Mr
For detailed usage information, see the source code.