Closed farling42 closed 11 months ago
You got it! This is a really cool orthogonal helper to put in.
Would you like the flag to be optional with a default to "g"? Asking on behalf of the "i" flag.
I ran a test with this helper, and here's what I'm seeing:
The helper:
export default function (text) {
return new RegExp(text, 'g');
}
Handlebars.compile(`{{ more-handlebars-helpers-sanitize (more-handlebars-helpers-replaceAll (more-handlebars-helpers-regexp value '\n<hr />') ' ') }}`)({ value: "Hello,\n<hr />there,\n<hr />world!"})
Result:
'/Hello,\\n<hr \\/>there,\\n<hr \\/>world!/g'
I'll keep digging to see why it's not working like we'd expect. If you see something in my test code above I could do differently, let me know.
Putting my bad test here in the public helped me fix my bad test 🤣
Updated test:
Handlebars.compile(`{{ more-handlebars-helpers-sanitize (more-handlebars-helpers-replaceAll value (more-handlebars-helpers-regexp '\n<hr />') ' ') }}`)({ value: "Hello,\n<hr />there,\n<hr />world!"})
Result:
'Hello, there, world!'
🎉
Concerning optional, I guess the RegExp could take a second optional parameter, which would be the flags passed as the second argument for the RegExp constructor. Much better for those who like more than just "g" :-)
Version 1.2.0 has released. Give it a go, and if things are working, go ahead and close the issue.
It is working just fine. Thanks for the rapid turn-around!
Thank you both! We have rendering stat-blocks!
It just needs the Trigger/Effect text better formatted now 😉
Baby-steps lol.
A user wants to strip out blank lines, but that requires a RegExp to be used.
A simple handler such as:
This will allow a user to use an expression to remove break lines from the HTML of item/actor descriptions, such as:
(The "\n" isn't recognised by the basic replaceAll function)