ructe
ructe copied to clipboard
html only?
why do the template files have to end in .html?
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. compile_templates picks up .rs.html compile_static_files picks up lot's of extensions including .rs (on which it crashed for me when last experimented with it)
@mocsy ;
I depend on compile_templates only picking up .html at the moment.
Why? Do you have your templates in your src
directory rather than in an specific templates
directory? If so, why?
I'm about to add compiling of templates named *.rs.svg
and *.rs.xml
besides *.rs.html
. I might add other formats in the future, but for other formats, other quoting rules should apply, and I don't want to imply support for such formats before there is actul support for those quoting rules.
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:
- src
- modules
- user
- login.rs
- login.rs.html
- register.rs
- register.rs.html
- ...
- api
- emails
- ... I think *.rs.svg and *.rs.xml and other would be neat.
- user
- modules
Ah, that should work even when picking up more template names. Even with more template formats, it will only assume a file named x.rs.y
is a template if y is a known template format (currently html, soon html, xml or svg, maybe more in the future).
It would be nice to allow manually set desired file extensions in configs. There would be nothing to do with escaping if we implement https://github.com/kaj/ructe/issues/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.
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 tomatotomatotomatosince 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. The de-facto standard nova-days is to write proc-macros, derives, or attributes. Those don't fit all use-cases, so it depends on what kind of rust code you actually want to generate and more importantly, when in the pipeline.
The de-facto standard nova-days is to write proc-macros, derives, or attributes. Those don't fit all use-cases, so it depends on what kind of rust code you actually want to generate and more importantly, when in the pipeline.
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?
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?
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.