2012-10-30 5 views
0

이 매크로는 라이브 서버에서 행복하게 실행됩니다. WebMatrix에서는 괜찮 았습니다. 이제 WebMatrix 2 (새로 고침) 자체를 업데이트했습니다, 그것은이 그들 중 하나되는 몇 가지 매크로를 실행하지 않습니다 : - ":"코드 블록의 시작에 유효하지 않습니다 그것은 불평Umbraco 면도기 구문 문제

@{ 
    //Check there are slider image page loaded 
    var theCount = @Model.Descendants("SliderImagePage").Count(); 

    if (theCount > 0) 
    { 
     foreach (var theImagePage in Model.Descendants("SliderImagePage")) 
      { 
      var theImage = theImagePage.Media("sliderImage","umbracoFile"); 
      if (theImagePage.IsFirst()) 
      { 
      @:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:block;"></div> 
      } else { 
      @:<div class="slide" style="background-image:url('@Html.Raw(theImage)');display:none;"></div> 
      } 
      }  
    } 
    else 
    { 
    @: No Picture Image pages set up 
    } 

} 

.

VS2010에 MVC4와 Razor Extensions가 있습니다. 내가 아는 한, 모두 유효합니다. 누구든지 인증을 통과하지 못할 이유를 밝힐 수 있습니까?

감사합니다. foreach는 루프에서

답변

2

명령문은 사용하지 않고 잘 실행해야 @ : 출력 : 당신이 면도기에서 컴파일 문제를 발견 한 것처럼

@{ 
    //Check there are slider image page loaded 
    var theCount = @Model.Descendants("SliderImagePage").Count(); 

    if (theCount > 0) 
    { 
     foreach (var theImagePage in Model.Descendants("SliderImagePage")) 
     { 
      var theImage = theImagePage.Media("sliderImage","umbracoFile"); 
      if (theImagePage.IsFirst()) 
      { 
       <div class="slide" style="background-image:url('@Html.Raw(theImage)');display:block;"></div> 
      } 
      else 
      { 
       <div class="slide" style="background-image:url('@Html.Raw(theImage)');display:none;"></div> 
      } 
     }  
    } 
    else 
    { 
     @: No Picture Image pages set up 
    } 
} 
+0

감사합니다, 그들을 제거하지만 VS2010은 여전히 ​​@에 대해 불평 : 없음 사진 이미지 라인이 너무 ("여기") @ Html.Raw에 넣어 없다 그리고 그것은 소집을 통과 한 것 같습니다. – Craig

1

것 같습니다. 간단한 해결 방법이 있습니다. 3 행에서 '@'문자를 제거하면 위에서 준 코드가 Razor v1과 Razor v2 모두에서 컴파일됩니다.

CodePlex의 웹 페이지 팀 버그 데이터베이스에이 버그가 있으며, 다음 버전에서 해결 될 예정입니다.

HTH, 클레이

+0

고마워요. 클레이. 해결 방법을 통해 내 모든 매크로를 수정하고 html 시작 및 종료 태그가 범위를 벗어난 것으로 보이는 매크로를 제외한 나머지 매크로를 사용할 수있게되었지만 다른 방법은 알 수 없습니다. <[email protected] (ulClass)> @foreach() { 여기에 코드 } 너무 길면 전체 코드를 여기에 입력 할 수 없습니다. – Craig

+0

안녕하세요 크레이그. 그 이유는 무엇입니까?

    @foreach() {code}
- Gareth/agrath – agrath