askama icon indicating copy to clipboard operation
askama copied to clipboard

Allow using arbitrary delimiters

Open Kijewski opened this issue 1 year ago • 6 comments

  • Allow delimiters with arbitrary length
  • Allow setting expr_start, etc. in Rust source

Kijewski avatar Apr 03 '23 17:04 Kijewski

Actually, using a single character as delimiter (even such a character as newline) (w|sh)ould work, but then it would be difficult to extend the language in the future if we have to assume that any and all characters are used in the wild.

Kijewski avatar Apr 03 '23 19:04 Kijewski

What are you trying to achieve here? Conceptually I don't really like the idea of giving Config access to the TemplateArgs.

djc avatar Apr 04 '23 08:04 djc

Well, 1st and foremost I wanted to remove the restriction that you have to use exactly two ASCII characters as delimiters. With this PR you can use any and all unicode characters. And then I find setting up a config file cumbersome. Right now you can already set the whitespace handling in the code where you derive the template, without needing to resort to using a config file. So I added the option to set the other parts of the configuration, too. I pass &TemplateArgs instead of adding six new parameters, because until Rust adds named parameters having so many parameters is quite error prone, esp. when every parameter has the same type.

Kijewski avatar Apr 04 '23 10:04 Kijewski

In the end I want to use askama to format a single latex file. Using braces as delimiters does not work very well in this context. Adding a config file would make the code less readable, IMO, because I have no code duplication anyway.

Kijewski avatar Apr 04 '23 10:04 Kijewski

Sorry for the slow feedback.

No problem at all!

What do you think about adding a new syntax config struct {whitespace, block_start, ..} that I would pass around? Instead of template_whitespace in the current version, or the whole TemplateArgs I in my PR proposed?

Kijewski avatar May 23 '23 21:05 Kijewski

What do you think about adding a new syntax config struct {whitespace, block_start, ..} that I would pass around? Instead of template_whitespace in the current version, or the whole TemplateArgs I in my PR proposed?

Sounds like a decent path forward? I'd have to see it in more detail to be sure, though.

djc avatar May 26 '23 10:05 djc

PR needs to be redone entirely, because the codebase changed entirely.

Kijewski avatar May 17 '24 17:05 Kijewski