On 1/19/23 6:24 PM, seany wrote:
Hello
Please consider this diet template:
doctype html
html(lang="es", dir="ltr")
head
meta(name="viewport", content="width=device-width,
user-scalable=no, initial-scale=1.0")
meta(charset="utf-8")
link(rel="stylesheet", type="text/css", href="main.css")
<link
href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700;800&display=swap" rel="stylesheet">
Did you mean to include straight HTML here? I don't think that is supported.
Please notice the line `form(id= ...`. This line is causing the
following error:
login.dt(29,45): Error: found `method` when expecting `;`
following `return` statement
login.dt(29,51): Error: found `=` instead of statement
login.dt(28,12): Error: missing closing `)` after `if ("form"`
login.dt(28,21): Error: found `)` when expecting `;` following
statement
login.dt(28,36): Error: found `method` when expecting `)`
login.dt(28,42): Error: found `=` when expecting `)`
login.dt(28,43): Error: found `""` when expecting `)`
login.dt(28,45): Error: found `)` instead of statement
/root/.dub/packages/diet-ng-1.8.1/diet-ng/source/diet/html.d(246,8):
Error: template instance
`diet.html.compileHTMLDietFileString!("login.dt", contents,
DefaultDietFilters).exec!(StreamOutputRange!(InterfaceProxy!(OutputStream), 1024LU))` error instantiating
/root/.dub/packages/vibe-d-0.9.5/vibe-d/http/vibe/http/server.d(351,66):
instantiated from here:
`compileHTMLDietFileString!(StreamOutputRange!(InterfaceProxy!(OutputStream),
1024LU))`
source/app.d(41,5): instantiated from here:
`render!"login.dt"`
What is the problem? How can I resolve it? Thank you.
The easiest way to see what the diet compiler is producing is to
uncomment the line that outputs the compiled file to the console during
compilation. That is located here:
https://github.com/rejectedsoftware/diet-ng/blob/856bf6d75127955565b3b5edd9b1f4418b8ec7c3/source/diet/html.d#L234
With that being said, how diet works is to convert the diet template
directly into D code. It relies on the translation to produce valid D
code (no specialized parsing or semantic-aware processing is done, it's
just a direct translation from diet AST to D). What is happening here is
the diet compiler is not producing valid D code. This can happen when
there are bugs, but usually only when there are D "escapes", which don't
correctly set up the syntax (like if you include a curly brace, which
isn't expected)
However, in your code, I don't see any "escapes", so I'm not sure what
could cause it there.
I will note that most of the time, when I get diet errors like that the
error is not on that specific line, but on something that happened
before to confuse the D compiler. That html `link` node might be the
issue, but again, I'm not sure what is intended there.
-Steve