-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for <condition> {}
loop does not work in templates $tmpl()
#23447
Comments
Connected to Huly®: V_0.6-21877 |
For variables you don't need the curly braces; just |
The error is reproduced despite the presence of curly braces. In addition, curly braces solve the parsing problem when the data in the template follows the variable name without spaces (e.g. dot at the end of a sentence). |
I have used |
Oh, it worked with:
V templating is so inconsistent... How about deprecate Also both |
for
loop does not work in templates $tmpl()
for <condition> {}
loop does not work in templates $tmpl()
I think V borrowed the template syntax of <script>
function discount(a) { alert('$' + 0.10*a); }
</script>
<table>
<tr><td>User</td><td>Discount</td></tr>
@for user in users
<tr>
<td>@user.name</td>
<td><button onclick = "discount(@user.payment)">$ Discount</td>
</tr>
@end
</table> |
I agree. I tried doing that, but it's pretty tricky. The templates need to be re-written with a real parser. |
V version: V 0.4.9 d2b30df, press to see full `v doctor` output
What did you do?
./v -g -o vdbg cmd/v && ./vdbg main.v && main
users.tmpl:
What did you see?
What did you expect to see?
Generated text with users list:
According to the documentation it should work.
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
The text was updated successfully, but these errors were encountered: