Yep, that worked! 

Using the inline filter, your macro definition would look like this:
> \define video(url, w:"400px", h:"300px")
> <iframe width="$w$" height="$h$" src={{{ [[$url$]removeprefix[https://
> www.youtube.com/watch?v=]addprefix[https://www.youtube.com/embed/]] }}} 
> frameborder="0" allowfullscreen></iframe>
> \end
>
 
As well as this: 

One more note... to make the code a bit easier to understand, you could use 
> a couple of variables to define the values of the prefixes and the modified 
> src URL, like this:
> \define video(url, w:"400px", h:"300px")
> <$vars old="https://www.youtube.com/watch?v="; new="
> https://www.youtube.com/embed/";>
> <$vars src={{{ [[$url$]removeprefix<old>addprefix<new>] }}}>
> <iframe width="$w$" height="$h$" src=<<src>> frameborder="0" 
> allowfullscreen></iframe>
> </$vars>
> </$vars>
> \end
>

And even this: 
 

> \define video(url, w:"400px", h:"300px")
> <iframe width="$w$" height="$h$" src={{{ $url$ +[split[watch?v=]join[embed
> /]] }}} frameborder="0" allowfullscreen></iframe>
> \end
>

 
In the end I decided to stick with this final macro:

\define vid(id, w:"534px", h:"300px")
<iframe src={{{ [[$id$]addprefix[https://www.youtube.com/embed/]] }}} 
width="$w$" height="$h$"  frameborder="0" allowfullscreen></iframe>
\end

and usage like: <<vid "ScjChJDp3mo">>

Don't want to deal with youtube.com/youtu.be and https:/http: in the future.

Btw, did I get it right that you don't need to specify 
(parameters/variables - whatever they're called) of the macro when calling 
it and if their names are omitted macro just handles them in a specified 
order?
So I don't need to write: <<vid id:"VIDEOID" w:"640" h:"360">> and I can 
write just <<vid "VIDEOID" "640" "360">>?


Thanks Eric and Mat! And Eric especially for the comprehensive lecture. Too 
bad it would be forever lost in the annals of this forum. I think it could 
be usefull to many other newbies. 
I think someone should seriously think about "TW Online Tutorial" (with 
some learning curve, cases, recipies etc), becase as I said earlier 
tiddlywiki.com <https://tiddlywiki.com/#SetWidget> is of course very 
usefull, but provide not very much in terms of "learning". In most cases 
there are just parameter descriptions and very basic usage. And Working 
with TiddlyWiki <https://tiddlywiki.com/#Working%20with%20TiddlyWiki> section 
is very limited as well. 

enjoying,
 \ (•◡•) /
 

-- 
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/c29b9afa-4295-4ca6-a02c-a0d6acf576dao%40googlegroups.com.

Reply via email to