BlazorEmbedLibrary 0.1.0-beta-3

This is a prerelease version of BlazorEmbedLibrary.
There is a newer version of this package available.
See the version list below for details.
dotnet add package BlazorEmbedLibrary --version 0.1.0-beta-3                
NuGet\Install-Package BlazorEmbedLibrary -Version 0.1.0-beta-3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorEmbedLibrary" Version="0.1.0-beta-3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BlazorEmbedLibrary --version 0.1.0-beta-3                
#r "nuget: BlazorEmbedLibrary, 0.1.0-beta-3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install BlazorEmbedLibrary as a Cake Addin
#addin nuget:?package=BlazorEmbedLibrary&version=0.1.0-beta-3&prerelease

// Install BlazorEmbedLibrary as a Cake Tool
#tool nuget:?package=BlazorEmbedLibrary&version=0.1.0-beta-3&prerelease                

BlazorEmbedLibrary

This is a component library that provides Blazor-style static file embedding for Razor Components/Blazor.

Chanegelog:

Version 0.1.0-beta-3
  • Restructure source folders
  • Add ability to handle multiple component assemblies in one go
  • Add ability to block specific content files -- Including in Blazor
Version 0.1.0-beta-2
  • Add compatibility with Pre-Rendering
Version 0.1.0-beta-1
  • Initial release
  • Enable support for embedded content files (CSS/JS) in Razor Components

Projects in this repo:

BlazorEmbedLibrary

This is the component library that provides all the functionality.

It is a netstandard component library (i.e. a netstandard2.0 library) with one c# code file.

How to use this library

Add the nuget package BlazorEmbedLibrary

https://www.nuget.org/packages/BlazorEmbedLibrary/

Add a Using and an addTagHelper to the __ViewImports file

@using BlazorEmbedLibrary
@addTagHelper *, BlazorEmbedLibrary

Then add the component to whichever page you want e.g. MainLayout, Index.cshtml - wherever makes sense for your project/needs.

<EmbeddedContent BaseType="@(typeof(Component1))" />

Note, by default the EmbeddedContent component has Debug turned off - if you enable it by setting Debug=true, it outputs the list of embedded resources.

This will read any CSS or Js files, which are embedded resources, from the Component1 library and add them to the head of the document.

Multiple Assemblies

From version 0.1.0-beta-3 onwards, you can now handle multiple component libraries in one hit using the Assemblies Parameter

<EmbeddedContent Assemblies="@Assemblies" />

@functions
{
List<System.Reflection.Assembly> Assemblies = new List<System.Reflection.Assembly>()
{
    typeof(BlazorComponentSample.Component1).Assembly,
    typeof(Blazored.Toast.BlazoredToasts).Assembly
};
}

Block Files

From version 0.1.0-beta-3 onwards, you can now block individual files using the BlockCss Parameter

This example will load content from Blazored.Toast and Component1, but will block the styles.css from BlazorComponentSample.

<EmbeddedContent Assemblies="@Assemblies" BlockCssFiles="@BlockCss" />

@functions
{
List<string> BlockCss = new List<string>()
{
    "BlazorComponentSample,styles.css"
};

List<System.Reflection.Assembly> Assemblies = new List<System.Reflection.Assembly>()
{
    typeof(BlazorComponentSample.Component1).Assembly,
    typeof(Blazored.Toast.BlazoredToasts).Assembly
};
}

Sample Projects

I have included Blazored.Toast and a simple custom component in the Razorcomponents and Blazor Apps

BlazorComponentSample

An out-of-the-box sample Blazor component library with static files.

BlazorEmbedContent - Runnable

A sample Blazor app to show how this library detects if Blazor has already linked the static files, and does not duplicate them.

Also shows how we can toggle CSS files on/off at runtime.

RazorComponentsSample.Server - Runnable

A sample Razor Components App to show static files working.

Also shows how we can toggle CSS files on/off at runtime.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 1,031 9/15/2019
0.1.0-beta-4 980 3/19/2019
0.1.0-beta-3 425 3/10/2019
0.1.0-beta-2 382 3/8/2019
0.1.0-beta-1 399 3/5/2019