According to the release v1.1.0 ( https://github.com/mozilla/nunjucks/releases/tag/v1.1.0 ), the filter replace should accept RegExps for the first argument.
I am trying this
... | replace( /(https?:\/\/[^ ]+)/ , "<a href=\"$1\">$1</a>" )
And it is triggering:
Template render error:
unexpected token: /
Am I being noob somewhere?
I am having the same problem
Looks like the syntax would be:
replace( r/(https?:\/\/[^ ]+)/ , "<a href=\"$1\">$1</a>" )
(note the r before the regexp)
hm...seems like by using the "r", it stop triggering the error.
But did not apply the replacement either!
Yes, you need to prepend the regex with r, like r/foo/. It probably wasn't matching the regexp which is why the replacement didn't occur. Please reopen/file a new issue if you still have problems!
This needs to be mentioned on the docs!
r/ This is a pit.
(This info is for others searching for REGEX among issues)
Hello, I know that's darn ol' thread.
Just wanna add little info - you should not be using quotation marks "" but use apostroph marks '' instead.
Otherwise you get some errors.
Most helpful comment
This needs to be mentioned on the docs!