MvcMovieGiraffe #456
dharmatech
started this conversation in
Show and tell
Replies: 2 comments 1 reply
-
Awesome, thanks for bringing this to my attention and thank you for your support! Is this project something you would like to add to the current collection of Giraffe samples? At least we should at a link to your repository in the README of the samples! |
Beta Was this translation helpful? Give feedback.
1 reply
-
Refactoring viewsThe original C# version of MvcMovie has the following in the Edit view: <div class="form-group">
<label asp-for="Title" class="control-label"></label>
<input asp-for="Title" class="form-control" />
<span asp-validation-for="Title" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ReleaseDate" class="control-label"></label>
<input asp-for="ReleaseDate" class="form-control" />
<span asp-validation-for="ReleaseDate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Genre" class="control-label"></label>
<input asp-for="Genre" class="form-control" />
<span asp-validation-for="Genre" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Price" class="control-label"></label>
<input asp-for="Price" class="form-control" />
<span asp-validation-for="Price" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Rating" class="control-label"></label>
<input asp-for="Rating" class="form-control" />
<span asp-validation-for="Rating" class="text-danger"></span>
</div> Now that the experimental tag helpers are in place, the corresponding code in the Giraffe version is: let form_group (expr : FSharp.Quotations.Expr<'a>) =
div [ _class "form-group" ]
[
TagHelpers.Label.Of(%expr, [ _class "control-label" ])
TagHelpers.Input.Of(%expr, [ _class "form-control" ])
TagHelpers.SpanValidation.Of(%expr, [ _class "text-danger" ])
]
form_group <@ model.Title @>
form_group <@ model.ReleaseDate @>
form_group <@ model.Genre @>
form_group <@ model.Price @>
form_group <@ model.Rating @> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The ASP.NET Core documentation includes an MVC tutorial for building a project called MvcMovies.
MvcMovieGiraffe is a port of that project to F#/Giraffe.
It's very rough around the edges but it runs and the various pages are there. It currently uses the in-memory database.
Beta Was this translation helpful? Give feedback.
All reactions