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

Add a conditional helper to mustache (php and js)

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Won't Fix
    • 2.9
    • None
    • Themes
    • MOODLE_29_STABLE
    • MDL-50167-master
    • Hide

      Pull the entire branch, including the testing commit on the end.

      Go to the template library - at the bottom of the page there will be a list of "WIN" lines on the page. This is the result of a template that uses all these conditionals. Any line with no text, or "LOSE" is a fail for the test.

      Now click on the "core/conditional" template to see the same template rendered by javascript. The result should be identical.

      Show
      Pull the entire branch, including the testing commit on the end. Go to the template library - at the bottom of the page there will be a list of "WIN" lines on the page. This is the result of a template that uses all these conditionals. Any line with no text, or "LOSE" is a fail for the test. Now click on the "core/conditional" template to see the same template rendered by javascript. The result should be identical.

    Description

      This would be a set of generic helpers that will evaluate a conditional and either print a section, or skip it.

      Example

      {{#lt replyCount "3"}}
        "Less than 3 replies"
      {{/lt}}
      

      Full set of new conditionals are:
      eq, neq, lt, gt, lte, gte, and, or

      The arguments for these conditionals are resolved to variables in the current context by default, but strings, numbers and booleans are recognised and passed as their correct types.

      Attachments

        Issue Links

          Activity

            People

              damyon Damyon Wiese
              damyon Damyon Wiese
              Ryan Wyllie Ryan Wyllie
              Huong Nguyen, Bas Brands, Mathew May
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: