On Thu, 13 Jun 2024 at 15:19, Hartmut Goebel
<[email protected]> wrote:
>
> 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          | [email protected]               |
> | www.crazy-compilers.com | compilers which you thought are impossible |
>
> --
> You received this message because you are subscribed to the Google Groups 
> "nikola-discuss" 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/nikola-discuss/bd31864e-41bc-436b-8331-f91082113284%40crazy-compilers.com.

Hi,

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?).

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" 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/nikola-discuss/CAMw%2Bj7JBxCva4DMVesPW9rByXGoBfgVgOisQTiUhkxU6WwTATQ%40mail.gmail.com.

Reply via email to