-
Notifications
You must be signed in to change notification settings - Fork 33
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
html only? #20
Comments
Currently, html is the only string escaping that's supported. It's a simple fix to allow any file name for templates, but I haven't really thought through how to handle string escaping for other formats yet. |
On second thought, though, .xml and .svg files (and some other xml-based formats) use the same escaping, and should be possible to use by only changing the filename-matching rules. I'll take a look at this. |
I depend on compile_templates only picking up .html at the moment. It would be neat if we could configure what extensions each template functions would pick up. |
@mocsy ;
Why? Do you have your templates in your I'm about to add compiling of templates named As for other xml-like formats, I'm open for suggestions for suffixes that would be useful. |
Instead of templates I have a modules folder like so I can organize an couple my code into modules, rather than crates. Had I used a separate templates folder, I'd have to use crates for each of those. Example:
|
Ah, that should work even when picking up more template names. Even with more template formats, it will only assume a file named |
Allow template source files to be named *.rs.svg or *.rs.xml along with *.rs.html. The generated template functions will simlilarly be suffixed _svg, _xml or _html (any template_html will get a template alias, for backwards compatibility. Helps #20.
* PR #55 from kornelski: Improve benchmarks. * Part of issue #20: Allow template source files to be named *.rs.svg or *.rs.xml as well as *.rs.html. The generated template functions will simlilarly be suffixed _svg, _xml or _html (any template_html will get a template alias, for backwards compatibility. * PR #61 from Eroc33: Improve parsing for tuple and generic type expressions. * Fix old doc link in readme. * Update dependencies in ructe and examples. Thaks to @kornelski and Eroc33.
* Issue #62: New version number due to abi breakage, reported by @kornelski. Otherwise same as 0.7.4: * PR #55 from kornelski: Improve benchmarks. * Part of issue #20: Allow template source files to be named *.rs.svg or *.rs.xml as well as *.rs.html. The generated template functions will simlilarly be suffixed _svg, _xml or _html (any template_html will get a template alias, for backwards compatibility. * PR #61 from Eroc33: Improve parsing for tuple and generic type expressions. * Fix old doc link in readme. * Update dependencies in ructe and examples. Thaks to @kornelski and Eroc33.
* Issue #62: New version number due to a semver-breaking change, reported by @kornelski. Otherwise same as 0.7.4: * PR #55 from kornelski: Improve benchmarks. * Part of issue #20: Allow template source files to be named *.rs.svg or *.rs.xml as well as *.rs.html. The generated template functions will simlilarly be suffixed _svg, _xml or _html (any template_html will get a template alias, for backwards compatibility. * PR #61 from Eroc33: Improve parsing for tuple and generic type expressions. * Fix old doc link in readme. * Update dependencies in ructe and examples. Thaks to @kornelski and Eroc33.
* Issue #62: New version number due to a semver-breaking change, reported by @kornelski. Otherwise same as 0.7.4: * PR #55 from kornelski: Improve benchmarks. * Part of issue #20: Allow template source files to be named *.rs.svg or *.rs.xml as well as *.rs.html. The generated template functions will simlilarly be suffixed _svg, _xml or _html (any template_html will get a template alias, for backwards compatibility. * PR #61 from Eroc33: Improve parsing for tuple and generic type expressions. * Fix old doc link in readme. * Update dependencies in ructe and examples. Thaks to @kornelski and @Eroc33.
It would be nice to allow manually set desired file extensions in configs. There would be nothing to do with escaping if we implement #2 |
Would using Ructe for genering templated Rust code an option? From what I understand from it, it was made with HTML in mind, but definitely not limited to it. Thoughts on that? Or is there better options than templates to generate Rust code? Please do not throw 🍅🍅🍅since I am a some-week-old Rustacean ;-) still getting to know the ecosystem. |
I think in ructe 0.8.0 template source files can be named *.rs.svg, *.rs.xml and *.rs.html, that suggests *.rs.rs won't load. Might not be too hard to fix that, but I let @kaj to judge. That being said, I built my first rust code generator in rust with the format! macro, which is enough to get something done quick. |
My current project idea is code generation from an OpenAPI Specification, generating all routes and value parsing logic and creating types for inputs and outputs, so in the end, only the pure business logic has to be implemented, returning a typed result. Hence the Rust code generation. |
Can we just allow any file extensions as is, without escaping? |
I guess we could, but that would essentially be a separate template engine, so maybe it should be a separate crate? |
Maybe. I wish there was a generic library for text/code generation with great controll over spaces. I use ructe to generate boilerplate human-readable SQL and JS code, 'cause I see no alternatives for that so far. I really like ructe concept and syntax. |
why do the template files have to end in .html?
The text was updated successfully, but these errors were encountered: