askama
askama copied to clipboard
Add support for generating templates in `no_implicit_prelude` modules
At the moment if the template deriving code is used in a module that uses no_implicit_prelude
, the code fails to compile because it uses unqualified identifiers from std
.
The fix implies using std::result::Result::Ok
for example instead of Ok
in the generated code.
Patches welcome. :)
Patches welcome. :)
@djc Yes, I intend to do so in the weekend, especially since this is an easy one.
(BTW, I am well aware this is an open-source project, and that especially feature requests should be closely followed by pull requests...) :)
I mainly opened this before the pull request to get some feedback before committing to the actual code.
I mainly opened this before the pull request to get some feedback before committing to the actual code.
Good thinking. I think I've provided feedback on all your issues now. :) Let me know if you need further pointers on how to implement/fix things.
I've started working on this, bellow is the diff that makes the necessary changes:
https://github.com/cipriancraciun/askama/compare/patches/upstream/no-implicit-prelude--base...cipriancraciun:patches/upstream/no-implicit-prelude
I'm unsure how to create thorough test-cases for this. I've copy-pasted the simple.rs
test-case, removed all actual testing code, and left only the structures.
(The code is based on-top of the two other issues I've been working on, regarding io::Write
and generic render
methods, thus once those two are accepted upstream, I'll send a pull request for this one.)
Until then, @djc could you review this?
I'm fine with the code generator changes. For the test changes, I don't like all the duplication. I propose you make one test case in an inline module at the bottom of simple.rs
, you can decide how complex you want to make the template used in there. Basically, this feature is of low value to me and I don't want myself or other contributors to spend much on supporting it.
OK, I've made the requested changes. Once the io::Write
(with the generic patch) is included I'll create a pull request for this one.