Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinmoris committed Dec 6, 2020
2 parents 1599dcc + 08027a8 commit d48d78c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
dotnet-version: 5.0.100
- name: Restore
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.301
dotnet-version: 5.0.100
- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

## 5.1.0-rc-1

- Upgraded to .NET 5
- Added an overload to the `AddRazorEngine` extension method to set if existing file providers should be kept or cleared via the `persistFileProviders` flag.

## 5.0.0

- Dropped support for all .NET framework monikers except .NET Core 3.1 (in preparation for the .NET 5 release)
Expand Down
4 changes: 2 additions & 2 deletions samples/GiraffeRazorSample/GiraffeRazorSample.fsproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AssemblyName>GiraffeRazorSample</AssemblyName>
<PackageId>GiraffeRazorSample</PackageId>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
Expand All @@ -26,4 +26,4 @@
</Content>
</ItemGroup>

</Project>
</Project>
11 changes: 7 additions & 4 deletions src/Giraffe.Razor/Giraffe.Razor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
<Authors>Dustin Moris Gorski and contributors</Authors>
<NeutralLanguage>en-GB</NeutralLanguage>

<!-- Tell NuGet to STFU -->
<NoWarn>$(NoWarn);NU5104</NoWarn>

<!-- Build settings -->
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<DebugType>portable</DebugType>
<OutputType>Library</OutputType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
Expand All @@ -31,7 +34,7 @@
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<NoWarn>FS2003</NoWarn>
<NoWarn>$(NoWarn);FS2003</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -42,8 +45,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Giraffe" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.0" />
<PackageReference Include="Giraffe" Version="5.0.0-rc-3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/Giraffe.Razor/Middleware.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ module Middleware =

type IServiceCollection with

member this.AddRazorEngine(viewsFolderPath: string) =
member this.AddRazorEngine(viewsFolderPath : string, persistFileProviders : bool) =
this.Configure<MvcRazorRuntimeCompilationOptions>(fun (options: MvcRazorRuntimeCompilationOptions) ->
options.FileProviders.Clear()
if not persistFileProviders then
options.FileProviders.Clear()
else
()
options.FileProviders.Add(new PhysicalFileProvider(viewsFolderPath))).AddMvc().AddRazorRuntimeCompilation()
|> ignore
this.AddAntiforgery()

member this.AddRazorEngine(viewsFolderPath : string) =
this.AddRazorEngine(viewsFolderPath, false)

member this.AddRazorEngine() =
this.AddMvc().AddRazorRuntimeCompilation() |> ignore
this.AddAntiforgery()
18 changes: 9 additions & 9 deletions src/Giraffe.Razor/RazorEngine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module RazorEngine =
open Microsoft.AspNetCore.Routing
open FSharp.Control.Tasks.V2.ContextInsensitive

let private extractRouteData (path:string) =
let private extractRouteData (path : string) =
// Normalize nulls
let templatePath = path + ""

Expand Down Expand Up @@ -43,14 +43,14 @@ module RazorEngine =

routeData

let renderView (razorViewEngine : IRazorViewEngine)
(modelMetadataProvider: IModelMetadataProvider)
(tempDataDict : ITempDataDictionary)
(httpContext : HttpContext)
(viewName : string)
(model : 'T option)
(viewData : IDictionary<string, obj> option)
(modelState : ModelStateDictionary option) =
let renderView (razorViewEngine : IRazorViewEngine)
(modelMetadataProvider : IModelMetadataProvider)
(tempDataDict : ITempDataDictionary)
(httpContext : HttpContext)
(viewName : string)
(model : 'T option)
(viewData : IDictionary<string, obj> option)
(modelState : ModelStateDictionary option) =
task {
let routeData = extractRouteData(viewName)
let templateName = routeData.Values.["action"].ToString()
Expand Down

0 comments on commit d48d78c

Please sign in to comment.