Skip to content

Commit

Permalink
Add support for Razor Components (XAMPPRocky#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
meenzen authored and ErikSchierboom committed Jun 7, 2024
1 parent 83cf62a commit b7624ab
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
7 changes: 5 additions & 2 deletions languages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1283,8 +1283,11 @@
"extensions": ["raku", "rakumod", "rakutest", "pm6", "pl6", "p6"]
},
"Razor": {
"multi_line_comments": [["<!--", "-->"], ["@*", "*@"]],
"extensions": ["cshtml"]
"line_comment": ["//"],
"multi_line_comments": [["<!--", "-->"], ["@*", "*@"], ["/*", "*/"]],
"quotes": [["\\\"", "\\\""]],
"verbatim_quotes": [["@\\\"", "\\\""]],
"extensions": ["cshtml", "razor"]
},
"Red": {
"line_comment": [";"],
Expand Down
55 changes: 55 additions & 0 deletions tests/data/razor.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
@* 55 lines 35 code 15 comments 5 blanks *@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace temp.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

@{
// foo
string foo = "bar";

/*
* bar
*/
string bar = "foo";
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="temp.styles.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png"/>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
@*
multi-line comment
*@
<component type="typeof(App)" render-mode="ServerPrerendered" />

<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<!--
different multi-line comment
-->
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>

<script src="_framework/blazor.server.js"></script>
</body>
</html>
45 changes: 45 additions & 0 deletions tests/data/razorcomponent.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@* 45 lines 16 code 21 comments 8 blanks *@
@page "/counter"

@{
// foo
string foo = "bar";

/*
* bar
*/
string bar = "foo";
}

<PageTitle>Counter</PageTitle>

@*
multi-line comment
*@
<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<!--
different multi-line comment
-->
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
/*
C# style multi-line comment
*/
private int currentCount = 0;

private void IncrementCount()
{
// increment the count
currentCount++;
}
}

0 comments on commit b7624ab

Please sign in to comment.