Comments (7)
Okay, that makes sense -- thanks. I have a feeling we need to go all the way to arbitrary Rust statements to solve your problem though. Maybe just a @let
special form would be enough?
I'll need to think about this a bit more.
from maud.
I have to say that I didn't need to do this so far, anything that should be run once can be run outside the macro, and the @if let
syntax allows for the rest
Note: I'm not trying to argue too hard against it, however it doesn't feel like something that is necessary.
from maud.
Implemented in 39602a0. The new @let
form is pretty much like @if let
, except the pattern cannot fail.
@Sackery I don't want to allow arbitrary Rust statements within a template. If your view logic is complicated enough that you need a whole block for it, then that's a sign that it should be in a separate function altogether.
from maud.
Can you give me an example of how such a feature would be used?
I've considered it in the past, but held back because I couldn't find a use case for it.
Note that you can declare variables outside the html!
block as well.
from maud.
because some situation e.g. @for n in 1..2 {}.
we want to insert normal rust expression to cache something.
from maud.
@for n in somethings {
div {
@ { // here are any rust normal code.
let item = n.something.unwrap(); // here item in something is move out, so we cannot unwrap twise.
}
h1 { (item.name) }
a { (item.age) }
}
}
from maud.
but maybe this is powerful and smart.
html! {
@ {
somefunction(); // I can run any rust code here.
}
}
from maud.
Related Issues (20)
- Allow for XML void tag syntax HOT 2
- Documentation question: unclear on toggles HOT 7
- Feature: Hot-reload / Runtime interpretor for debug mode HOT 1
- Compiler error? HOT 3
- Allow colons in attribute names HOT 1
- aggressive minification HOT 6
- not an issue, just a tip for working with tailwind + maud HOT 3
- Bump axum-core to 0.4
- Need some help with the rocket response HOT 1
- Update rocket support to 0.5 (stable) HOT 1
- Reflexion on my usage HOT 5
- split ast into a separate crate to write our own implementations which use maud syntax
- Shouldn't `escape_to_string` escape `'` characters? HOT 2
- Maud will need updating for Axum 7.0+ HOT 1
- Document recent changes to attribute name syntax
- How to make attributes use single quotes
- Bad parsing with attribute splices HOT 1
- Syntax hlighting & formatting in editors? HOT 1
- Document the way to create a full document HOT 2
- Empty class when all optional classes are omitted HOT 1
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 maud.