XML literals Enhancements to be more supportive to Vazor: the built-in VB syntax Razor!
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
In this proposal https://github.com/aspnet/AspNetCore/issues/8674 (please all VB.NET fans, support it), I suggested to use xml literals to implement ASP.NET MVC razor in VB.NET instead of vbhtml files, like this:
```VB.NET
Friend Class View1
Dim Model As IEnumerable(Of MvcMusicStore.Models.Genre)
Public Sub New(model As IEnumerable(Of MvcMusicStore.Models.Genre))
Me.Model = model
ViewBag.Title = "Store"
End Sub
'ViewBag.Title = "Store"
Public ReadOnly Property Razor
Get
Return _
Browse Genres
Select from <%= Model.Count() %> genres:
- <%= genre.Name %> ) %>
<%= (From genre In Model Select
End Get
End Property
End Class
```
In this code, I used LinQ because I need to return a value to be embedded in the xml literal. I tried another way:
```VB.NET
- <%= genre.Name %>
<%= (Iterator Function()
For Each genre In Model
Yield
Next
End Function)() %>
```
Using inline lambdas like this, makes it possible to evaluate any expression with any VB code we want, but I think this can be simplified and shortened as this:
```VB.NET
- <%= genre.Name %>
<%= For Each genre In Model
Yield
Next %>
```
This is more like a vbhtml razor page code!
The suggestion is simply to write any vb.net code directly inside the `<%= %>` marks, and use return or Yield to return the desired value that will be used in the xml literal. Return and Yield here are scoped to the Xml literal, and all what VB.NET needs to do, is to wrap all this inside
```
([Iterator] Function( )
End Function)()
```
Where [Iterator] is added if Yield is used in code.
Another example:
```VB.NET
- One Item
- Two Items
- Many Items
<%= Select Case Model.Count
Case 1
Return
Case 2
Return
Case Else
Return
End Select %>
```
Which is a shortcut for:
```VB.NET
- One Item
- Two Items
- Many Items
<%= (Function()
Select Case Model.Count
Case 1
Return
Case 2
Return
Case Else
Return
End Select
End Function)() %>
```
I hope these proposal are taken seriously. VB.NET is too powerful and has many precious hidden treasures, and it is really unfortunate that MS decided to left VB.NET behind to save some effort and money, while VB.NET could have been saved too much time , effort and money spent to develop Razor syntax, while it is already supported in VB syntax!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.