-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
User-defined escaping #136
Comments
I think something like that could work. I think there are a few different things to be considered -- like how we make this sufficiently general to be usable for a number of different things. Can you say more about your exact use case and what it needs? Your request seems to imply that you'd be okay just triggering on the same characters that are currenly escaped in On the other hand, the current architecture/interface is sort of built on the notion that different file types need different escaping modes, so that seems the most clean way to plug in. We might be able to rearrange the current HTML escaping code so that it's easier to plug in a different mapping, though. |
I believe it should be more general that just triggering on the same characters that are currently escaped in html.
This is the idea I think is important. Almost all the templating engines (especially for Rust) mainly look at HTML templates. It would be great to be able to use askama for more general applications. For example, the project I'm looking at right now is templating markdown and LaTeX. In the LaTeX case, I might want to escape special latex characters (e.g. |
In that case I think there is a relatively straightforward solution. I propose that we indeed define another table structure in the configuration, which could look something like this: [escape.latex]
filter = "latex_mod::escape"
extensions = ["tex"] This will enable the Does that sound right? And if so, are you willing to work on an implementation? |
This is probably nice-to-have for 0.8, and might not make it. |
We can use https://doc.rust-lang.org/cargo/reference/build-scripts.html#case-study-code-generation for generate
Than through the syntax " You can write from askama.toml and have the most common, (latex, html, etc,) saved. That is to say,
How about? |
About the options that you told me, rocket included, I attached the benches report with the comparison with the current one, rocket and v_escape. So it would, be logical, on the configuration table adding the options to create the escape function using v_escape. Benchesv_escapehttps://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L991
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L1052
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L1074
askama_escapehttps://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L851
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L913
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L935
rockethttps://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L715
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L775
https://travis-ci.org/rust-iendo/v_htmlescape/jobs/471740072#L797
@djc Can you tell me what you think? |
On the other hand, there is a cyclical dependence between askama_shared ( |
See #197. |
Feature Request:
Would it be possible to allow users the ability to define a custom escape mapping in the
askama.toml
, similar to how a user can define a custom syntax?I'm not entirely sure what this would look like so this issue is just a place to discuss the idea.
The text was updated successfully, but these errors were encountered: