Merge branch 'MDL-70721-master' of git://github.com/rezaies/moodle
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -572,6 +572,25 @@ function(
|
||||
return '[[_s' + index + ']]';
|
||||
};
|
||||
|
||||
/**
|
||||
* String helper to render {{#cleanstr}}abd component { a : 'fish'}{{/cleanstr}}
|
||||
* into a get_string following by an HTML escape.
|
||||
*
|
||||
* @method cleanStringHelper
|
||||
* @private
|
||||
* @param {object} context The current mustache context.
|
||||
* @param {string} sectionText The text to parse the arguments from.
|
||||
* @param {function} helper Used to render subsections of the text.
|
||||
* @return {string}
|
||||
*/
|
||||
Renderer.prototype.cleanStringHelper = function(context, sectionText, helper) {
|
||||
var str = this.stringHelper(context, sectionText, helper);
|
||||
|
||||
// We're going to use [[_cx]] format for clean strings, where x is a number.
|
||||
// Hence, replacing 's' with 'c' in the placeholder that stringHelper returns.
|
||||
return str.replace('s', 'c');
|
||||
};
|
||||
|
||||
/**
|
||||
* Quote helper used to wrap content in quotes, and escape all quotes present in the content.
|
||||
*
|
||||
@@ -718,6 +737,7 @@ function(
|
||||
this.requiredJS = [];
|
||||
context.uniqid = (uniqInstances++);
|
||||
context.str = this.addHelperFunction(this.stringHelper, context);
|
||||
context.cleanstr = this.addHelperFunction(this.cleanStringHelper, context);
|
||||
context.pix = this.addHelperFunction(this.pixHelper, context);
|
||||
context.js = this.addHelperFunction(this.jsHelper, context);
|
||||
context.quote = this.addHelperFunction(this.quoteHelper, context);
|
||||
@@ -761,13 +781,14 @@ function(
|
||||
* @return {String} The treated content.
|
||||
*/
|
||||
Renderer.prototype.treatStringsInContent = function(content, strings) {
|
||||
var pattern = /\[\[_s\d+\]\]/,
|
||||
var pattern = /\[\[_(s|c)\d+\]\]/,
|
||||
treated,
|
||||
index,
|
||||
strIndex,
|
||||
walker,
|
||||
char,
|
||||
strFinal;
|
||||
strFinal,
|
||||
isClean;
|
||||
|
||||
do {
|
||||
treated = '';
|
||||
@@ -777,8 +798,9 @@ function(
|
||||
// Copy the part prior to the placeholder to the treated string.
|
||||
treated += content.substring(0, index);
|
||||
content = content.substr(index);
|
||||
isClean = content[3] == 'c';
|
||||
strIndex = '';
|
||||
walker = 4; // 4 is the length of '[[_s'.
|
||||
walker = 4; // 4 is the length of either '[[_s' or '[[_c'.
|
||||
|
||||
// Walk the characters to manually extract the index of the string from the placeholder.
|
||||
char = content.substr(walker, 1);
|
||||
@@ -791,11 +813,15 @@ function(
|
||||
// Get the string, add it to the treated result, and remove the placeholder from the content to treat.
|
||||
strFinal = strings[parseInt(strIndex, 10)];
|
||||
if (typeof strFinal === 'undefined') {
|
||||
Log.debug('Could not find string for pattern [[_s' + strIndex + ']].');
|
||||
Log.debug('Could not find string for pattern [[_' + (isClean ? 'c' : 's') + strIndex + ']].');
|
||||
strFinal = '';
|
||||
}
|
||||
if (isClean) {
|
||||
strFinal = mustache.escape(strFinal);
|
||||
}
|
||||
treated += strFinal;
|
||||
content = content.substr(6 + strIndex.length); // 6 is the length of the placeholder without the index: '[[_s]]'.
|
||||
content = content.substr(6 + strIndex.length); // 6 is the length of the placeholder without the index.
|
||||
// That's either '[[_s]]' or '[[_c]]'.
|
||||
|
||||
// Find the next placeholder.
|
||||
index = content.search(pattern);
|
||||
|
||||
Reference in New Issue
Block a user