Skip to content

Conversation

@alexkazik
Copy link

This allows for using external html, when it's a big chunk it's better to read when not part of the rust file.

html_file!("templates/base.maud");

It will be searched relative to the project root.

I've tested this only on top of #322 and rocket 0.5 support, not on actual main but it should be of no difference.

Copy link
Owner

@lambda-fairy lambda-fairy left a comment

Choose a reason for hiding this comment

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

Hi @alexhazik, thanks for the PR!

This looks like a reimplementation of std::include!.

In general, Maud aims to reuse built-in Rust features like modules and functions to organize its templates. So I prefer not to add features in that area.

For these reasons I will close this PR. Let me know if you have any follow up questions!

@alexkazik
Copy link
Author

include reads a file and places it in the code so it will be compiled as rust code.

html_file reads a maud template and returns a Html with the template.

And you could use include to do the same but would have to include html! in it, this looks as if it's made for it.

I've done this because it's similar to Haskell's Shakespeare, and they also have macros for in-line and in file.

@alexkazik alexkazik deleted the html-file branch June 16, 2022 13:36
@alexkazik
Copy link
Author

This PR has a little bug anyway.

But it would be a good idea to add an include! example to the website.

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 this pull request may close these issues.

2 participants