Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zapateo opened this issue Dec 13, 2024 · 0 comments
Labels
proposal templates Related to the template

Comments

@zapateo
Copy link
Member

zapateo commented Dec 13, 2024

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.

@zapateo zapateo added proposal templates Related to the template labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal templates Related to the template
Projects
None yet
Development

No branches or pull requests

1 participant