Code Monkey home page Code Monkey logo

Comments (4)

djc avatar djc commented on August 23, 2024

It's possible we don't support as casts. Maybe 51_i64 is supported? I forget...

from askama.

realGWM avatar realGWM commented on August 23, 2024

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.

djc avatar djc commented on August 23, 2024

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.

Kijewski avatar Kijewski commented on August 23, 2024

In the meantime using i64::from(51) should work.

from askama.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.