Using Chirpy with Razor Syntax

Dec 15, 2011 at 12:40 PM



I've just started using Chirpy (Both v2.01 and v2.03), and whilst it works great with .js and .css files, I'm having a bit of trouble with any Razor Syntax.


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


@{ ViewBag.Title = "Blah"}

@section Styles{ ... }

@section Scripts{ ... }



In various places I use @foreach loops, and use a either "@:" or <text> 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 .@ test.chirp.cshtml 3 26

Error 62 syntax error test.chirp.cshtml 5 16

Error 63 invalid property id test.chirp.cshtml 22 20

Error 67 missing ; before statement test.chirp.cshtml 28 59


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


Could anyone help?

Thanks again for an awesome tool - it's definitely going to be used for css and js accross my site.




Dec 17, 2011 at 11:39 PM

Send sample project with error.

In test project work with (empty error) :

    ViewBag.Title = "Test";
@section Styles{
@foreach (var item in ViewBag.Prod)
@section Scripts{
Jan 27, 2012 at 11:32 AM

Hi Ploufs,

Wow, I apologise for not getting back to you on this.

The problem is that I have Razor syntax mixed in with my scripts, thus stopping minification from working.

Ideally, when minification reaches an @{} block, or a  @foreach loop, the content should be ignored.

As an example:

<script type="text/javascript">
    var prices = [
    @foreach(var p in Model.Prices)
        @: @p.LowestPrice

   // Alert first entry



Will not work with Chirpy...



Mar 11, 2012 at 5:10 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.