将 Chirpy 与 Razor 语法结合使用

发布于 2024-12-21 11:36:41 字数 1178 浏览 2 评论 0原文

我刚刚开始使用 Chirpy(v2.01 和 v2.03 - http://chirpy.codeplex.com/< /a>),虽然它与 .js 和 .css 文件配合得很好,但我在 VS 2010 中使用任何 Razor 语法时遇到了一些麻烦。

本质上,我有一个 Razor 文件,看起来像如下:

@{ ViewBag.Title = "Blah"}

@section Styles{ ... }

@section Scripts{ ... }

html

在不同的地方,我使用 @foreach 循环,并使用“@:” 或 来通知什么是代码以及要输出什么。

总而言之,Chirpy 给了我数百个错误。它们都是:

Error 60 "missing name after .@" 

Error 62 "syntax error" 

Error 63 "invalid property id" 

Error 67 "missing ; before statement" 

Error 68 "illegally formed XML syntax" 

cshtml 文件实际上没有问题,因为它们都在 firefox/chrome 中完美运行,没有错误。

有人可以帮忙吗?如果有的话,我会喜欢一些内联 js 压缩。

我也在 codeplex 网站上发布了此查询(如果收到回复,我会报告): http:// /chirpy.codeplex.com/discussions/283079

如果所有其他方法都失败,我将跳入代码(它是开源的)。任何人都提供比这里更好的起点: http://chirpy .codeplex.com/SourceControl/changeset/view/d003dad47915#Engines%2fViewEngine.cs

干杯, 达兹。

I've just started using Chirpy (Both v2.01 and v2.03 - http://chirpy.codeplex.com/), and whilst it works great with .js and .css files, I'm having a bit of trouble with any Razor Syntax in VS 2010.

Essentially, I have a Razor file which looks like follows:

@{ ViewBag.Title = "Blah"}

@section Styles{ ... }

@section Scripts{ ... }

html

In various places I use @foreach loops, and use a either "@:" or to notify what is code and what is to be output.

All said and done, Chirpy gives me hundreds of errors. They are all either:

Error 60 "missing name after .@" 

Error 62 "syntax error" 

Error 63 "invalid property id" 

Error 67 "missing ; before statement" 

Error 68 "illegally formed XML syntax" 

There are actually no problems in the cshtml files as they all run perfectly in firefox/chrome with no errors.

Could anyone help? Would love some inline js minification if it's available.

I have posted this query on the codeplex site also (and will report back if I get a response): http://chirpy.codeplex.com/discussions/283079

If all else fails, I'll jump into the code (it's open source). Anyone offer a better place to start than here: http://chirpy.codeplex.com/SourceControl/changeset/view/d003dad47915#Engines%2fViewEngine.cs ?

Cheers,
Daz.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风夜微凉 2024-12-28 11:36:41

据我从代码中看到,Chirpy 正在使用其“常规”转换引擎来缩小 CSS 和 JS。

这意味着缩小引擎不知道剃刀。因此,您不能使用 razor 代码,这可能会被缩小引擎错误解释。这几乎排除了一切。

实际上,这确实很有意义,因为缩小器只能处理扩展代码,像这样的东西,只是不能“缩小”(对于 .less / css 也是如此):

   <script>
        @for(int i = 0; i < 10: i++) {
            var k@i = @(i * i);
        }
        alert(k@(variable_from_razor));
   </script>

As far as I can see from the code, Chirpy is using its "regular" conversion engines to minify the CSS and JS.

This means the minifying engines doesn't know razor. So you cannot use razor code, that could be mis-interpreted by the minifying engine. This pretty much excludes everything.

Actually, this does make a lot of sense, since the minifier can only work on expanded code, something like this, just cannot be "minified" (same is true for .less / css):

   <script>
        @for(int i = 0; i < 10: i++) {
            var k@i = @(i * i);
        }
        alert(k@(variable_from_razor));
   </script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文