aboutsummaryrefslogtreecommitdiffstats
path: root/testing/templates (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-06-12Allow macros to be defined and called without argumentsLibravatar mataha1-0/+21
This commit introduces a shorthand for defining and calling macros when using them as a reusable substitute for variables assigned complex values (e.g. string literals with or without newline escapes). The use-case is formatting - from my experience it's easier to visually parse a `macro` `endmacro` block than a multiline variable assignment. Signed-off-by: mataha <mataha@users.noreply.github.com>
2023-03-06Propogate size_hint from sub-blocks (#788)Libravatar Andrew Dona-Couch -- GitHub drop ICE3-0/+5
Closes #786
2022-04-29Allow `{% endmacro name %}`Libravatar Bastien Orivel1-0/+12
Just migrated a repo from tera to askama and this was one of the only things that was different. This is also coherent with `{% block %}` for which I added the same feature years ago.
2022-02-16Make json filter safeLibravatar René Kijewski1-1/+1
Previously the built-in json filter had an issue that made it unsafe to use in HTML data. When used in HTML attributes an attacker who is able to supply an arbitrary string that should be JSON encoded could close the containing HTML element e.g. with `"</div>"`, and write arbitrary HTML code afterwards as long as they use apostrophes instead of quotation marks. The programmer could make this use case safe by explicitly escaping the JSON result: `{{data|json|escape}}`. In a `<script>` context the json filter was not usable at all, because in scripts HTML escaped entities are not parsed outside of XHTML documents. Without using the safe filter an attacker could close the current script using `"</script>"`. This PR fixes the problem by always escaping less-than, greater-than, ampersand, and apostrophe characters using their JSON unicode escape sequence `\u00xx`. Unless the programmer explicitly uses the safe filter, quotation marks are HTML encoded as `&quot`. In scripts the programmer should use the safe filter, otherwise not.
2021-11-29Allow whitespace trimming in {{raw}} blocksLibravatar René Kijewski1-0/+2
2021-08-30Add {% break %} and {% continue %}Libravatar René Kijewski1-0/+11
This PR adds `{% break %}` and `{% continue %}` statements to break out of a loop, or continue with the next element of the iterator.
2021-08-25Add test case for matching on Option<bool>Libravatar Restioson1-0/+8
2021-07-30Issue #379 was fixedLibravatar René Kijewski2-0/+28
This PR adds the tests by @msrd0 <git@msrd0.de> that failed before. The error was fixed somewhen between f23162a and now, so these tests serve to prevent regressions in the future. I simplified the tests very slightly to omit whitespaces in the output.
2021-07-30Use "target()" to parse "when" blockLibravatar René Kijewski1-0/+10
`target()` as used in parsing "let" and "if let" implements parsing nested tuples and structs. But it does not implement parsing literals. The functions `match_variant()` and `with_parameters()` as used in parsing "when" blocks do not implement parsing nested structs, but it implements parsing literals. This PR combines `match_variant()` and `with_parameters()` into `target()`, so that all `{%when%}` support nested structs, too.
2021-07-05Add tuple destructoring testsLibravatar René Kijewski1-0/+3
2021-07-02Replace rust_macro test to work on nightlyLibravatar René Kijewski1-3/+3
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-01Add "if let" testsLibravatar René Kijewski4-0/+10
2021-06-22Fix code generation for macro calls that store args in variables.Libravatar Ryan Kelly1-0/+9
2021-03-10Added path and ext testsLibravatar vallentin3-0/+3
2020-12-25Added let shadow testLibravatar vallentin1-0/+22
2020-12-01Improved if statement generation to avoid issues with implicit borrows (#392)Libravatar Christian Vallentin1-0/+51
* Changed to automatically coerce to bool * Added new test case * Updated test case to include else if
2020-12-01Fixed implicit borrow of expressions (#390)Libravatar Christian Vallentin1-0/+9
2020-08-25Use efficient method for nested template renderingLibravatar Dirkjan Ochtman1-3/+3
2020-07-20Fix additional clippy issueLibravatar Dirkjan Ochtman1-1/+1
2020-07-20Clean up clippy issuesLibravatar Dirkjan Ochtman1-2/+1
2020-06-30Add tests for allow whitespaces patchLibravatar Ciprian Dorin Craciun1-0/+63
2020-01-29Move Iron integration into a separate askama_iron crateLibravatar Dirkjan Ochtman1-1/+0
2020-01-12Add new templatesLibravatar Dirkjan Ochtman2-0/+6
2020-01-12Support escaping in string literalsLibravatar Tuomas Siipola1-0/+2
Do not attempt to parse escape sequences thoroughly. Instead let the Rust compiler to check the string literals and provide nice error messages if necessary.
2020-01-03Support char literalsLibravatar Tuomas Siipola2-0/+9
2019-10-09Reformat test for better readabilityLibravatar Dirkjan Ochtman1-15/+3
2019-10-09Limit test sensitivity to macro pretty printing outputLibravatar Dirkjan Ochtman1-14/+3
See https://github.com/rust-lang/rust/issues/65207.
2019-10-08Add support for boolean literalsLibravatar Dave Poulter1-0/+2
2019-04-18WIP: Add raw blockLibravatar Pavel Fokin2-0/+8
2019-03-18Move small templates into source codeLibravatar Dirkjan Ochtman2-4/+0
2019-03-18Documenting feature render in templateLibravatar Vicente Ramirez Perea3-0/+10
2019-01-08Add support for loop.lastLibravatar yossyJ2-2/+2
2019-01-08Allow trailing commas in tuples (#188)Libravatar yossyJ1-1/+1
2019-01-04Add support for tupleLibravatar yossyJ2-0/+4
2018-12-13fix rust macro argumentsLibravatar Juan Aguilar Santillana1-0/+26
2018-12-12Allow using brackets for enums in `match`Libravatar mcarton1-2/+2
2018-10-20Add test for unescaped variable expressions (see #132)Libravatar Qian Linfeng1-0/+5
2018-10-08Clean up warning about unused fieldLibravatar Dirkjan Ochtman1-1/+1
2018-10-07Add Rust macro support at templatesLibravatar bott1-0/+1
2018-09-21fix panicked on range-based for loopLibravatar bott1-0/+15
2018-09-14Fix operator preference at loop.indexLibravatar bott1-1/+1
2018-09-14Fix operator preference at loop.firstLibravatar bott1-0/+3
2018-09-07Fix deep nested imports in macro callsLibravatar bott3-2/+8
2018-09-02Fix multiple nesting in macro calls into different scopesLibravatar bott1-2/+6
2018-09-02Add test for nested macro calls into different scopeLibravatar bott2-0/+9
2018-06-28Add benchmarks to the Askama repoLibravatar Dirkjan Ochtman2-0/+20
2018-06-25Add test for 'loop.first' variableLibravatar Dirkjan Ochtman1-1/+1
2018-06-23Add test for range operatorsLibravatar Dirkjan Ochtman1-0/+5
2018-06-22Add test for 'super' macroLibravatar Dirkjan Ochtman1-0/+1
2018-06-22Add test for deep inheritanceLibravatar Dirkjan Ochtman3-0/+43