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

✏️ feature: add FuncMap to Slim engine #252

Merged
merged 2 commits into from
May 20, 2023
Merged

Conversation

efectn
Copy link
Member

@efectn efectn commented May 20, 2023

This PR adds funcmap to Slim that wasn't added in the past.

Slim doesn't seem to support map[string]interface{} type for funcMap. So we have to change type of funcMap or assert interface to slim function. I prefered asserting not to break compatibility with other engines.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
for key, val := range e.funcMap {
slimFunc, ok := val.(slimFunc)
if !ok {
panic("slim: function must be compatible with slim.Func type. Slim does not support other types")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use panic, error or just continue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @gaby @ReneWerner87

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic seems to be okay

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panic seems to be okay

But this works inside of Render. Is it good idea to panic on requests?

@ReneWerner87 ReneWerner87 merged commit 9bb1ab0 into master May 20, 2023
@efectn efectn deleted the slim-funcmap branch May 20, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants