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

Handlebars helper removes extra get_string arguments

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.6, 2.8.4
    • Fix Version/s: 2.7.8, 2.8.6
    • Component/s: JavaScript
    • Labels:
    • Testing Instructions:
      Hide

      Regression test

      1. Go to an Atto instance and click the Insert media button.
        • Verify that the language strings appear as intended.

      Functionality test

      1. Open lib/editor/atto/plugins/media/lang/en/atto_media.php and modify the following lang strings accordingly:
        • $string['entername'] = 'Enter name {$a->what}';
        • $string['createmedia'] = '{$a->foo}{$a->bar}';
      2. Clear your Moodle's cache.
      3. Open lib/editor/atto/plugins/media/yui/src/button/js/button.js and modify TEMPLATE:

            TEMPLATE = '' +
                '<form class="atto_form">' +
                    '<label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label>' +
                    '<input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
                    '<button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button>' +
                    '<label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component what="whatwhatwhat"}}</label>' +
                    '<input class="fullwidth {{CSS.NAMEINPUT}}" type="text" id="{{elementid}}_atto_media_nameentry"' +
                            'size="32" required="true"/>' +
                    '<div class="mdl-align">' +
                        '<br/>' +
                        '<button class="submit" type="submit">{{get_string "createmedia" component foo="moodle" bar="opensource"}}</button>' +
                    '</div>' +
                '</form>';
        

      4. Rebuild your Javascript - i.e. navigate to lib/editor/atto/plugins/media/yui/src/button and run shifter.
      5. Go to an Atto instance and click the Insert media button.
        • Verify that the language strings appear as intended.
      Show
      Regression test Go to an Atto instance and click the Insert media button. Verify that the language strings appear as intended. Functionality test Open lib/editor/atto/plugins/media/lang/en/atto_media.php and modify the following lang strings accordingly: $string ['entername'] = 'Enter name {$a->what}'; $string ['createmedia'] = '{$a->foo}{$a->bar}'; Clear your Moodle's cache. Open lib/editor/atto/plugins/media/yui/src/button/js/button.js and modify TEMPLATE: TEMPLATE = '' + '<form class="atto_form">' + '<label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label>' + '<input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' + '<button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button>' + '<label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component what="whatwhatwhat"}}</label>' + '<input class="fullwidth {{CSS.NAMEINPUT}}" type="text" id="{{elementid}}_atto_media_nameentry"' + 'size="32" required="true"/>' + '<div class="mdl-align">' + '<br/>' + '<button class="submit" type="submit">{{get_string "createmedia" component foo="moodle" bar="opensource"}}</button>' + '</div>' + '</form>'; Rebuild your Javascript - i.e. navigate to lib/editor/atto/plugins/media/yui/src/button and run shifter . Go to an Atto instance and click the Insert media button. Verify that the language strings appear as intended.
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-49442-master

      Description

      As per topic - it is currently impossible to use language strings which take parameters in Handlebars, i.e.

      {{get_string "and" moodle one="Jekyll" two="Hyde"}}
      

      does not work.

      This is caused by our Handlebars get_string helper popping the Handlebars object off the end of the argument list, which would ordinarily be okay but said object contains a hashtable of additional keys.

      The fix is simple - grab the aforementioned hashtable and push it onto the back of the argument list. M.util.get_string will handle the rest gracefully without complaint or need for modification.

        Attachments

          Activity

            People

            Assignee:
            jethac Jetha Chan
            Reporter:
            jethac Jetha Chan
            Peer reviewer:
            Zachary Durber Zachary Durber
            Integrator:
            Dan Poltawski Dan Poltawski
            Tester:
            John Okely John Okely
            Participants:
            Component watchers:
            Andrew Lyons, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              11/May/15