Hi.
I have defined some variables svg_icon_home, svg_icon_blog,
svg_icon_mastodon. These are for inlining the icons, which are
rather small.
A template-based shortcode shall get the name of the icon to use as an argument and then call the respective function. Of course, I don't want to write a long if-elif-elif case-handling with hard-coded names. But I want to calculate the function name based on the parameter and then call the function.
Like this:
$($svg_icon_{$name}()}
How can I do this?
(I did not yet try this, since my template-based shortcode is not yet working, see my other post.)
Thanks in advance for any answer.
-- Regards Hartmut Goebel | Hartmut Goebel | h.go...@crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible |
variable variables tend to be a bad idea. Check Mako docs, there might be a way to handle this — although you might be happier with defining a dictionary (in GLOBAL_CONTEXT?).
Mako has
<%call expr="my_func()" />
Anyhow, this does not allow embedded expressions.
I'll probably will take a different approach and use CSS to include the icons.
Thanks anyway.