Open teaalltr opened 3 years ago
HI @Piruzzolo,
Can you add also a small example to reproduce the problem?
Thanks.
Can you add also a small example to reproduce the problem?
Sure:
module main
import vweb
struct App {
vweb.Context
}
fn main() {
mut app := App {}
vweb.run(app, 8081)
}
['/index']
pub fn (app &App) index() vweb.Result {
return $vweb.html()
}
and in index.html
:
<html>
<script src="https://unpkg.com/htmx.org@1.5.0"></script>
<body>
</body>
</html>
Here the files for convenience (zipped because GitHub doesn't support the file type): blog.zip
Use @@
if you don't want it changed.
Otherwise, you could be doing a template replacement, even in a URL.
@JalonSolov thanks, that's a neat workaroud
I think we shouldn't close it, the problem is still present in the code and a workaround can't be the the definitive solution @JalonSolov
Why not? It's not a workaround, it's the way to escape the @ to get a literal @ instead of a template replacement.
The same as you have to escape other characters in strings, etc. For example, if you wanted to print a literal ${
in V, you would have to escape the $
or V will think you're doing string interpolation. Every language in existence requires escaping something...
Indeed but having to skip it is not what a user would expect I guess. At least I didn't expect it at all
Then at the very least, it needs to be documented better.
I think it would be nice to have a special template directive, which prevents parsing within {...}
Maybe something like
@raw {
<div>@include 'header/base'</div>
}
In this case, parser wouldn't try to include './header/base.html' rather just output as is.
Many other template engines provide such functionality. e.G. Twig with {% verbatim %}
(https://twig.symfony.com/doc/3.x/tags/verbatim.html)
It looks like
@
is a valid character in urls/links. V template engine wrongly replaces it to$
The problem in the code should be somewhere here.Here is my bug report:
V version: V 0.2.4 d329e1d OS: Win 10
What did you do? Written
<script src="https://unpkg.com/htmx.org@1.5.0"></script>
in a html template.@
got replaced with$
What did you expect to see?
What did you see instead?