Open cschmatzler opened 3 years ago
It's not possible currently to call a macro like that, e.g. {% call foo(call bar()) %}
.
If the icon
always results in {% call icon::create(icon) %}
, then you can move that part into your initial macro
, i.e.:
{% macro link(href, icon, text) %}
{% call icon(icon) %}
{% endmacro %}
{% macro icon(class) %}
...
{% endmacro %}
{% call link("foo", "bar", "baz") %}
Another alternative could be to turn the icon
macro
into a function, e.g.:
#[derive(Template)]
#[template(path = "foo.html")]
struct FooTemplate {}
fn foo(class: &str) -> String {
class.to_string()
}
Then you can keep the initial macro
as is, and use it like this:
{% call link("foo", self::foo("bar"), "baz") %}
Hi,
I am trying to create some components as macros, but I cannot figure out how to use a component inside a component. Let me show you what I am trying to do with an example:
navigation_item.html
:I also have macros for svg icons, such as
Now, in my navigation template, how would I insert a specific icon into the navigation item? What I'd like to do is
{% call navigation_item::create("/", call icon::create("..."), "Home") %}
.I have also tried passing the icon name as string and then doing
{% import "components/icons/{{ icon }}.html" as icon}
inside thenavigation_item::create
macro, but that does not work.Is there any way to accomplish this?