Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upUser-defined escaping #136
Comments
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
lukehsiao
commented
Oct 21, 2018
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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? |
djc
referenced this issue
Nov 5, 2018
Open
recognize a template instance and don't bother escaping it #108
This comment has been minimized.
This comment has been minimized.
|
This is probably nice-to-have for 0.8, and might not make it. |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
|
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? |
This comment has been minimized.
This comment has been minimized.
|
On the other hand, there is a cyclical dependence between askama_shared ( |
djc
referenced this issue
Jan 6, 2019
Open
Publishing 0.8 to Cargo and general timeline question #191
This comment has been minimized.
This comment has been minimized.
|
See #197. |
lukehsiao commentedOct 21, 2018
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.