Comments (4)
It's possible we don't support as
casts. Maybe 51_i64
is supported? I forget...
from askama.
Nope, doesn't work either :(
use askama::Template;
#[derive(Template)]
#[template(ext = "txt", source = r#"
{% let a = 51 %} // works
{% let a = 51_i64 %} // does not work
"#)]
struct HelloTemplate {}
fn main() {
let a = 51_i64; // sanity check that it works in normal Rust code
let hello = HelloTemplate {};
println!("{}", hello.render().unwrap());
}
from askama.
Okay, well, if you want to try hacking it in, the code for binary expressions is around here:
https://github.com/djc/askama/blob/main/askama_parser/src/expr.rs#L107
If you can submit a patch with a basic test I'm happy to review it and/or provide more guidance.
from askama.
In the meantime using i64::from(51)
should work.
from askama.
Related Issues (20)
- global variables HOT 5
- Associated functions on structs with generics are not callable HOT 2
- How could i get session flash message in a view after redirect HOT 2
- Question: How should I return templates in actix-web HOT 2
- Cannot specify single named argument in macro HOT 5
- 0.12.1 only allow lower-case variable name in template HOT 5
- Keep the template source code portion corresponding to each AST token HOT 9
- Allow to have namespace for macros HOT 1
- Allowing imports and macro declaration everywhere? HOT 2
- I could not give relative path to template on linux but can give on windows HOT 7
- Issue
- Regression in askama_parser 0.2.0 update HOT 14
- Composing templates HOT 3
- 8e03fa6132669383a763d628b7443d1758b50400 HOT 1
- Document the `fmt` filter HOT 3
- Can't render simple template. Axum integration. HOT 2
- Add support for filter section HOT 5
- Document how integration should be imported HOT 1
- Remove the need to import askama itself when using integration crates HOT 3
- Why if block does not work inside another block HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from askama.