Forum Discussion
luk
Boss
pp_01 It is technically possible to manipulate OOB components, if it is performant and a good idea in general is the other question, but I know, sometimes there is just no other way...so here you go:
<#-- create a variable that holds the original component's markup --> <#assing markup> <@delegate /> </#assign> <#-- as $markup basically contains a string of HTML, you can do whatever you can with a string and manipulate it... --> <#-- replace stuff --> <#assign markup = markup?replace("<RegEx>", "<Replace>", "rmis") /> <#-- regex pattern matching --> <#assign matches = markup?matches("<RegEx>", "rmis") /> <#if matches> <#-- if you have capture groups you can get them with ?groups --> <#list matches?groups as match> <#-- do something with your match, which will contain all the capture groups as a sequence --> </#list> </#if> <#-- whenever you are done, just save stuff back to $markup (or any other variable, the name doesn't matter) and output the modded version --> ${markup}
Lindsey
6 years agoLeader
Hey luk , I tried this solution and I get this error:
For "?replace" left-hand operand: Expected a string or something automatically convertible to string (number, date or boolean), but this has evaluated to a markup_output
I also get an error if I try to convert markup to a string before doing this. How were you able to do this?
Related Content
- 8 months ago
- 18 days ago
- 5 years ago