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

Suggestion: Adding resolve? for macro Path #4370

Closed
paulcsmith opened this issue May 3, 2017 · 1 comment · Fixed by #4408
Closed

Suggestion: Adding resolve? for macro Path #4370

paulcsmith opened this issue May 3, 2017 · 1 comment · Fixed by #4408

Comments

@paulcsmith
Copy link
Contributor

paulcsmith commented May 3, 2017

I'm working on some libraries where it would be helpful to give better error messages for when things are missing. Here is an example

macro render(page)
  {% page.resolve? %}
    {{page}}
  {% else %}
    {% raise "You must create a page called #{page} that inherits from BasePage in src/views" %}
  {% end %}
end

render IndexPage

If there were a resolve? that returned whether the type was available or not, this would solve the problem. What do you think about something like that?

@paulcsmith paulcsmith changed the title Suggestion: Add resolve? for macro Path Suggestion: Adding resolve? for macro Path May 3, 2017
RX14 added a commit to RX14/crystal that referenced this issue May 12, 2017
mverzilli pushed a commit that referenced this issue May 14, 2017
* Add Path#resolve? macro method

Closes #4370
@paulcsmith
Copy link
Contributor Author

Thanks @RX14!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant