Comments (5)
That's not possible, but you could simply have a macro in the scope of your #[derive(Template)]
:
macro_rules! log_debug {
($($tt:tt)*) => {{
#[cfg(debug_assertions)] {
::log::debug!($($tt)*);
}
}}
}
{% call log_debug!("debug info here") %}
from askama.
That's not possible, but you could simply have a macro in the scope of your
#[derive(Template)]
:macro_rules! log_debug { ($($tt:tt)*) => {{ #[cfg(debug_assertions)] { ::log::debug!($($tt)*); } }} }{% call log_debug!("debug info here") %}
I see, that would do pretty much what i described.
However, in the template i would want to print the info into the template, like this:
<!--
Memory: 0.2/16GB Available
Chrome memory usage: 14GB
-->
{% cfg(debug_assertions) %}
blah blah blah
{% endcfg %}
Is that kind of syntax possible? It is not described anywhere in the docs IIRC. The thing is i want that code to be completely excluded from the production build, as it gets rather massive over time
from askama.
I think this should work:
{% if cfg!(debug_assertions) %}
blah blah blah
{% endif %}
from askama.
I think this should work:
{% if cfg!(debug_assertions) %} blah blah blah {% endif %}
Thanks, i will try! Not sure that this will compile out the code tho, but it might work
from askama.
Yup, that did work and that code is compiled out. Thanks!
from askama.
Related Issues (20)
- Fuzzing askama_parser results in panic HOT 3
- Can I pass None as arg to a macro? HOT 4
- Variable use with inheritence HOT 5
- askama_derive update breaks filter usage with spaces HOT 2
- question: xml templates support HOT 2
- relative template paths and include_str support HOT 7
- Generic iterator field for a template HOT 6
- `num as {integer}` cast does not work? HOT 4
- Suggestion: improve external API for adding framework integrations HOT 3
- Allow to have named arguments in macro HOT 5
- Filters and binary OR operations are easily confused HOT 10
- Problems comparing integers HOT 1
- SVG support HOT 4
- is it possible to use imports with filters, or make the import an expression? HOT 1
- Macro with unknown variants in match block compiles HOT 6
- Feature request: enhance match to include multiple targets HOT 1
- 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
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.