Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38133

html_writer: add shortcuts for very frequent tags

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.1
    • Fix Version/s: 2.5
    • Component/s: Libraries

      Description

      The html_writer class is generally convenient and safe but can result in rather long code. For example, if you want to add some accesshide text:

      echo html_writer::tag('span', $str, array('class' => 'accesside'));
      

      The problem is exacerbated when you are creating a structure of multiple tags.

      I propose creating shortcut methods for div and span, which are the most common structural tags. The shortcuts should also make it easier to add a CSS class as this is usually required for structural tags. This will allow for shorter code. (Other tags can continue to use the current methods.)

      Proposed code:

      echo html_writer::span($str, 'accesside');
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/May/13