On Sunday, July 5, 2020 at 1:31:34 AM UTC-7, Mat wrote:
>
> There's now actually a convenient split+join filter operator combination 
> that makes it simple to replace a string for another
> \define video(url, w:"400px", h:"300px")
> <iframe width="$w$" height="$h$" src={{{ $url$ +[split[watch?v=]join[embed
> /]] }}} frameborder="0" allowfullscreen></iframe>
> \end
>

Good catch!  This does make the replacement much simpler. 

The split[] chops the URL into two parts and automatically removes the 
"watch?v=" syntax.
Then, the join[] connects those two parts together and automatically 
inserts the "embed/" syntax.

One minor tweak I would suggest: enclose the $url$ in brackets just in case 
it contains something that would otherwise break the filter:
src={{{ [[$url$]split[watch?v=]join[embed/]] }}}

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/652b7f3e-256d-4cf7-a75c-98a605b56203o%40googlegroups.com.

Reply via email to