Merge pull request #696 from tomfulton/fix/u4-6655
Fix U4-6655: RTE Macro not rendering in backoffice when "macroAlias" is not first attribute
This commit is contained in:
@@ -15,7 +15,7 @@ function macroService() {
|
||||
|
||||
//This regex will match an alias of anything except characters that are quotes or new lines (for legacy reasons, when new macros are created
|
||||
// their aliases are cleaned an invalid chars are stripped)
|
||||
var expression = /(<\?UMBRACO_MACRO macroAlias=["']([^\"\'\n\r]+?)["'][\s\S]+?)(\/>|>.*?<\/\?UMBRACO_MACRO>)/i;
|
||||
var expression = /(<\?UMBRACO_MACRO (?:.+)?macroAlias=["']([^\"\'\n\r]+?)["'][\s\S]+?)(\/>|>.*?<\/\?UMBRACO_MACRO>)/i;
|
||||
var match = expression.exec(syntax);
|
||||
if (!match || match.length < 3) {
|
||||
return null;
|
||||
|
||||
@@ -40,6 +40,18 @@ describe('macro service tests', function () {
|
||||
expect(result.macroParamsDictionary.test2).toBe("hello");
|
||||
});
|
||||
|
||||
it('can parse syntax for macros when macroAlias is not the first parameter', function () {
|
||||
|
||||
var result = macroService.parseMacroSyntax("<?UMBRACO_MACRO test=\"asdf\" test2='hello' macroAlias='Map.Test' />");
|
||||
|
||||
expect(result).not.toBeNull();
|
||||
expect(result.macroAlias).toBe("Map.Test");
|
||||
expect(result.macroParamsDictionary.test).not.toBeUndefined();
|
||||
expect(result.macroParamsDictionary.test).toBe("asdf");
|
||||
expect(result.macroParamsDictionary.test2).not.toBeUndefined();
|
||||
expect(result.macroParamsDictionary.test2).toBe("hello");
|
||||
});
|
||||
|
||||
it('can parse syntax for macros with aliases containing whitespace and other chars', function () {
|
||||
|
||||
var result = macroService.parseMacroSyntax("<?UMBRACO_MACRO macroAlias='Map Test [Hello\\World]' test=\"asdf\" test2='hello' />");
|
||||
|
||||
Reference in New Issue
Block a user