Devmachinist.Xavier.AspNetCore
7.0.4
dotnet add package Devmachinist.Xavier.AspNetCore --version 7.0.4
NuGet\Install-Package Devmachinist.Xavier.AspNetCore -Version 7.0.4
<PackageReference Include="Devmachinist.Xavier.AspNetCore" Version="7.0.4" />
<PackageVersion Include="Devmachinist.Xavier.AspNetCore" Version="7.0.4" />
<PackageReference Include="Devmachinist.Xavier.AspNetCore" />
paket add Devmachinist.Xavier.AspNetCore --version 7.0.4
#r "nuget: Devmachinist.Xavier.AspNetCore, 7.0.4"
#addin nuget:?package=Devmachinist.Xavier.AspNetCore&version=7.0.4
#tool nuget:?package=Devmachinist.Xavier.AspNetCore&version=7.0.4
Xavier Framework
The Xavier Framework is a powerful framework designed to facilitate the development of web applications by providing support for multiple programming languages, including C#, Python, and JavaScript. It allows you to define and process template strings in both C# and JavaScript, ensuring seamless integration and efficient development. Xavier also offers server-side rendering capabilities, enabling full-page rendering for enhanced performance and SEO.
Table of Contents
Installation
To use Xavier, follow these steps using the cli:
- dotnet add package Devmachinist.Xavier
- or dotnet add package Devmachinist.Xavier.AOT
Usage
Template Syntax
The Xavier Framework recognizes three types of languages:
x{ ... }x
- This syntax denotes a C# execution. Any code within these tags will be interpreted as C# code.{{ ... }}
- This syntax represents as JavaScript in a script tag. Code within these tags will be interpreted as JavaScript code.py{ ... }py
- This syntax represents as python 3.4 IronPython. Code within these tags will be interpreted as python code.
Creating a Component
To create a component using the Xavier Framework, follow these steps:
- Create a new file with the
.xavier
extension (e.g.,MyComponent.xavier
). - Define your component within the
.xavier
file using the appropriate afformentioned syntax. - Implement the code behind for the component in a separate file with the same name as the component and a
.xavier.cs
extension (e.g.,MyComponent.xavier.cs
). Use the base class provided by Xavier Framework and match it with the component's code behind file.
Server-Side Rendering
Xavier Framework supports server-side rendering, which provides benefits like improved performance and search engine optimization (SEO). To enable server-side rendering for Xavier pages, follow these steps:
- Configure your web application to use Xavier Framework by running
dotnet add package Devmachinist.Xavier.AspNetCore
. - Use the
app.MapXavierNodes
method in your application's configuration to map the Xavier nodes to specific routes. This method specifies the URL pattern and the destination directory for Xavier pages. - Set the static fallback for Xavier.
- Add the using statement
using Xavier.AspNetCore;
using Xavier;
using Xavier.AOT
memory.StaticFallback("c:/fallback/index.html");
//app build
app.MapXavierNodes("{controller=Home}/{action=Index}/{id?}", Environment.CurrentDirectory + "/Pages", memory);
Initialization
To initialize Xavier in a .NET app, follow these steps:
- Import the required namespace:
using Xavier;
//and
using Xavier.AOT;
Call the Init
method to initialize Xavier with the desired parameters. This method builds your assembly into the specified destination. The last part of the destination path should have a .js
extension.
var memory = new Xavier.Memory();
await memory.Init(root, destination, assembly);
Or with AOT, pass in your memory object without calling memory.Init()...
Parallel.Invoke(async () =>
{
await aot.Init(
memory,
Environment.CurrentDirectory,
Environment.CurrentDirectory + "/Live/Xavier",
null,
typeof(Program).Assembly
);
});
## Examples
Here's an example of a `.xavier` file that demonstrates the usage of template strings in C# and JavaScript within the Xavier Framework:
```html
<div id="${this.target}auth">
</div>
{{
let username = "";
var target = '${this.target}'
}}
x{
// C# Code here
var Items = new[]{"item1","item2","item3"};
@foreach( var k in items){
<div>
@k
</div>
}
}x
Here is the code behind required for each component.
//this file should be named MyComponent.xavier.cs
using Xavier;
namespace MyNamespace{
public partial class MyComponent : XavierNode
{
new public bool? ShouldRender = true;
public MyComponent(XavierNode xavier) : base(xavier){
}
public MyComponent(){
}
}
}
Information
- Xavier is experimental and should be treated as such.
- Known to cause thread pool starvation while using Devmachinist.Xavier.AOT. Simply stop the app when done testing and use the memory.Init(root,destination,assembly) for production.
Contributing
We welcome contributions from the community to enhance the Xavier Framework. If you find any issues, have suggestions for improvements, or would like to add new features, please submit a pull request.
License
The Xavier Framework is released under the MIT License. Feel free to use, modify, and distribute it according to the terms of this license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net7.0
- Devmachinist.Xavier (>= 7.0.4)
- Microsoft.AspNetCore.Authorization (>= 7.0.4)
- Microsoft.AspNetCore.Connections.Abstractions (>= 7.0.4)
- Microsoft.AspNetCore.CookiePolicy (>= 2.2.8)
- Microsoft.AspNetCore.Http.Connections.Client (>= 7.0.4)
- Microsoft.AspNetCore.Http.Connections.Common (>= 7.0.4)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.2.5)
- Microsoft.AspNetCore.SignalR.Client (>= 7.0.4)
- Microsoft.AspNetCore.SignalR.Common (>= 7.0.4)
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 | |
---|---|---|---|
7.0.4 | 172 | 4/14/2024 |