972 Commits

Author SHA1 Message Date
René Kijewski
9e7fe8f2f9 Allow using "with" keyword in "let" statements
Askama uses the syntax `{% when Variant with (parameters) %}` in
`{% match %}` blocks.

This change allows the optional use of the keyword "with" in "let" and
"if let" statements, too.
2021-07-30 11:45:56 +02:00
Dirkjan Ochtman
136e55c8cf Silence clippy warning from Rust 1.54 2021-07-30 10:39:00 +02:00
René Kijewski
7e227907fe Implement destructoring of structs
This PR implements the destructoring of structs on the lhs of "let" and
"for" statements.
2021-07-05 14:17:49 +02:00
René Kijewski
3055c4b521 Add "destructoring tuple in loop" test 2021-07-05 13:48:41 +02:00
René Kijewski
44c0623a58 Add tuple destructoring tests 2021-07-05 13:48:41 +02:00
René Kijewski
8adee24836 Parse nested tuples in "let" statement lhs 2021-07-05 13:48:41 +02:00
René Kijewski
20a5f7af7b Add loop variable shadowing test 2021-07-05 10:34:20 +02:00
René Kijewski
4d92ed520c Reduce code duplication for writing targets
This change also fixes a bug in the loop generator, which failed for
shadowed variables.
2021-07-05 10:34:20 +02:00
René Kijewski
5c367f5021 Move logic where target shadows or declares a variable into method 2021-07-05 10:34:20 +02:00
René Kijewski
6e754506d8 Remove needless deref, only to ref it a few lines down 2021-07-05 10:34:20 +02:00
René Kijewski
db6c1b2b4a Remove duplicated code in generator 2021-07-05 10:34:20 +02:00
René Kijewski
ce4a0932d5 Prepare generator::visit_target() for nested targets
By now only non-nested tuples are accepted by the parser, but this will
change. This change makes visit_target() call itself for items in a
tuple. So enable the function to call itself, I needed to fix the
lifetime annotation, because the references inside a Target instance may
outlife a reference to instance itself.
2021-07-05 10:34:20 +02:00
René Kijewski
e9badca257 Replace rust_macro test to work on nightly
The current rust_test uses `stringify!()`. The documentation gives us
the warning:

> Note that the expanded results of the input tokens may change in the
> future. You should be careful if you rely on the output.

In the current nightly rust the result was indeed changed, so the test
not fails.

This PR replaces the test with another macro, that does not depend on
`stringify!()`.

Closes issue #504.
2021-07-02 16:37:11 +02:00
René Kijewski
c31fe5f3fc Fix expected error message for missing file
rust-lang/rust#82069 made error message that stem macro invocations more
verbose. Since Rust 1.54 (currently in beta) the message includes the
name of the offending macro.

This PR uses version_check to select the appropriate expected error
message.
2021-07-02 16:12:42 +02:00
Dirkjan Ochtman
8bb3de0a3e Stop eliding lifetimes in paths 2021-07-01 16:10:43 +02:00
René Kijewski
83b03cd485 Add "if let" tests 2021-07-01 10:24:32 +02:00
René Kijewski
06d2eee4a0 Implement "if let" statement 2021-07-01 10:24:32 +02:00
René Kijewski
5afabbc7e3 Use "if let Some(_)" instead of match 2021-07-01 10:24:32 +02:00
René Kijewski
c3e8b2cc72 Move visit_match_params into its own method 2021-07-01 10:24:32 +02:00
René Kijewski
c1fa2d6146 Fix a clippy::needless-borrow warning in askama_shared 2021-07-01 10:20:56 +02:00
vallentin
017b5901fb Added loop tests 2021-06-23 21:34:17 +02:00
vallentin
e70e8f7c1d Fixed loop generator when accessing field (fixes 494) 2021-06-23 21:34:17 +02:00
Ryan Kelly
49252d2457 Fix code generation for macro calls that store args in variables. 2021-06-22 11:41:45 +02:00
Shritesh Bhattarai
b318d7cbcd
Support rocket 0.5.0-rc.1 based on @flo-l's PR (#495)
See #412 for earlier iteration.
2021-06-15 15:45:19 +02:00
Dirkjan Ochtman
25eae265a2 Fix needless borrowing 2021-06-14 11:47:13 +02:00
Alex Wennerberg
c0e75554d2
Remove forward-slash escape (#486)
This was based off of the OWASP XSS prevention cheat sheet --
https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html#output-encoding-rules-summary

However, there isn't really any attack vector based on forward slash alone, and
it's being removed in the next version of that document.

> There is no proof that escaping forward slash will improve
> defense against XSS, if all other special characters are escaped
> properly, but it forces developers to use non-standard implementation of
> the HTML escaping, what increases the risk of the mistake and makes the
> implementation harder.

https://github.com/OWASP/CheatSheetSeries/pull/516
2021-05-17 21:33:47 +02:00
vallentin
92df4d1fe4 Fixed not found in scope error 2021-04-29 13:08:49 +02:00
Dirkjan Ochtman
c7b87bae4f Tweak dependabot ignore settings 2021-04-29 11:45:03 +02:00
SamJakob
4ea3df92a1
Add section to README for IDE plugins (#474) 2021-04-29 11:42:00 +02:00
dependabot-preview[bot]
0d42f8ece4 Upgrade to GitHub-native Dependabot 2021-04-29 10:43:46 +02:00
SciStarterOwner
451ef35011
Use raw identifiers for identifiers which collide with Rust keywords (#476)
Co-authored-by: Daniel Arbuckle <djarb@highenergymagic.org>
2021-04-21 09:27:18 +02:00
Dirkjan Ochtman
d43faa89f1 Eliminate common tails from branches 2021-04-13 07:10:52 +02:00
Dirkjan Ochtman
9232cafb66 askama_tide: suppress clippy::from-over-into lint 2021-03-30 09:59:12 +02:00
Dirkjan Ochtman
c0e01318ac Use mem::take() where applicable 2021-03-30 09:59:12 +02:00
Dirkjan Ochtman
46792fe843 Rename test types to PascalCase 2021-03-30 09:59:12 +02:00
mbuscemi
4ca966178c updated the book to describe the new paragraphbreaks filter 2021-03-22 13:23:08 +01:00
mbuscemi
e018c4a427 added paragraphbreaks function 2021-03-22 13:23:08 +01:00
Dirkjan Ochtman
e1d607f993 askama_gotham: bump version to 0.12.0 2021-03-22 09:38:02 +01:00
Dirkjan Ochtman
495b978cea askama_gotham: bump to 0.6 2021-03-22 09:38:02 +01:00
technic93
6a230cb358 Update version in README.md 2021-03-21 21:32:38 +01:00
technic93
f3f2a7e206 fix typo in docstring 2021-03-14 20:33:49 +01:00
vallentin
7b954cd788 Added path and ext tests 2021-03-10 13:09:56 +01:00
vallentin
d6c05d8eb9 Changed to allow both path and ext 2021-03-10 13:09:56 +01:00
vallentin
606c68dd34 Added extension tests 2021-03-10 13:09:56 +01:00
vallentin
8566d8258a Fixed extension to ignore common jinja extensions (fixes #457) 2021-03-10 13:09:56 +01:00
vallentin
7291494e6a Refactored getting path extension 2021-03-10 13:09:56 +01:00
Dirkjan Ochtman
96a4328d64 Fix style suggestion per nightly clippy 2021-02-28 21:51:53 +01:00
vallentin
5a799af090 Reworked constants to be parsed as paths 2021-02-23 09:51:27 +01:00
vallentin
bfeaf5d6d8 Added option test 2021-02-22 13:50:09 +01:00
vallentin
a07a1d8b7b Added var and path parser tests 2021-02-22 13:50:09 +01:00