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

Add #file_exists? Top-level Macro Method #10489

Closed
wants to merge 0 commits into from

Conversation

toddsundsted
Copy link
Contributor

Useful when composing the name of a file to read from in a macro.

I use this in my Kemal applications to create a render helper that takes a file name and checks for various flavors of templates using the name:

render "objects/index" # checks for and renders index.html.ecr, index.html.slang, etc.

The alternative is to use #read_file? as a check for existence. (Maybe there's another way that I'm missing.)

@straight-shoota
Copy link
Member

Could you please open an issue as feature discussion first? It can reference this PR. But this helps to keep general discussion of the feature separate from implementation details. Thank you.
It would be great to show how this improves code compared to #read_file?.

@Sija
Copy link
Contributor

Sija commented Mar 10, 2021

Aside of the more substantial arguments that method should be called sth like file_exists?, since exists? is too generic for a top-level method.

@toddsundsted
Copy link
Contributor Author

good suggestions! done!

Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

If you would rename the macro to file_exists?, I think this is good to go.

@straight-shoota straight-shoota linked an issue Mar 29, 2021 that may be closed by this pull request
@toddsundsted
Copy link
Contributor Author

@straight-shoota done!

@asterite asterite changed the title Add #exists? Top-level Macro Method Add #file_exists? Top-level Macro Method Mar 29, 2021
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.

Add #file_exists? Top-level Macro Method
4 participants