Skip to content

proposal: template: consider supporting function declarations inside imported files in templates #965

@zapateo

Description

@zapateo

Description

Consider supporting function declarations inside imported files in templates.

Use case

This is useful in all cases where an imported file, which contains macro declarations, needs to use a function written in Go. Currently the only way seems to be to declare a function literal inside a multiline statement in the macro, and this, in addition to being visually heavy and confusing, prevents the use of that function in other macros in the same file.

Possible syntax

A possible syntax could be that of the multiline statement with a func declaration inside as: {%% func F(...) { ... } %%}. Obviously this should be at the top level in the file.

Consequences on extend

Check whether this change can have consequences (desirable or not) also on the functioning of the extend, in addition to the import. This needs to be explored in more detail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions