diff --git a/vlib/v/parser/tmpl.v b/vlib/v/parser/tmpl.v index a6992f4d20..1679e5b905 100644 --- a/vlib/v/parser/tmpl.v +++ b/vlib/v/parser/tmpl.v @@ -218,6 +218,10 @@ mut sb := strings.new_builder($lstartlength)\n // replace `$` to `\$` at first to escape JavaScript template literal syntax source.writeln(line.replace(r'$', r'\$').replace(r'$$', r'@').replace(r'.$', r'.@').replace(r"'", r"\'")) + } else if state == .css { + // disable template variable declaration in inline stylesheet + // because of some CSS rules prefixed with `@`. + source.writeln(line.replace(r'.$', r'.@').replace(r"'", r"\'")) } else { // HTML, may include `@var` // escaped by cgen, unless it's a `vweb.RawHtml` string diff --git a/vlib/v/tests/inout/file.html b/vlib/v/tests/inout/file.html index 4e15416c55..e7eb9366ed 100644 --- a/vlib/v/tests/inout/file.html +++ b/vlib/v/tests/inout/file.html @@ -6,6 +6,11 @@ h1 { color: green; } + +@keyframes mymove { + from {top: 0px;} + to {top: 200px;} +}