RazorLight | Template engine based on Microsoft 's Razor parsing engine

 by   toddams C# Version: v2.3.1 License: Apache-2.0

kandi X-RAY | RazorLight Summary

kandi X-RAY | RazorLight Summary

RazorLight is a C# library typically used in Template Engine applications. RazorLight has no vulnerabilities, it has a Permissive License and it has medium support. However RazorLight has 3 bugs. You can download it from GitHub.

Use Razor to build templates from Files / EmbeddedResources / Strings / Database or your custom source outside of ASP.NET MVC. No redundant dependencies and workarounds in pair with excellent performance and .NET Standard 2.0 and .NET Core 3.0 support.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              RazorLight has a medium active ecosystem.
              It has 1394 star(s) with 247 fork(s). There are 62 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 65 open issues and 339 have been closed. On average issues are closed in 43 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of RazorLight is v2.3.1

            kandi-Quality Quality

              RazorLight has 3 bugs (0 blocker, 0 critical, 3 major, 0 minor) and 0 code smells.

            kandi-Security Security

              RazorLight has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              RazorLight code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              RazorLight is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              RazorLight releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              RazorLight saves you 53 person hours of effort in developing the same functionality from scratch.
              It has 139 lines of code, 0 functions and 163 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of RazorLight
            Get all kandi verified functions for this library.

            RazorLight Key Features

            No Key Features are available at this moment for RazorLight.

            RazorLight Examples and Code Snippets

            No Code Snippets are available at this moment for RazorLight.

            Community Discussions

            QUESTION

            Trying and failing to render two tables side by side with HTML and Bootstrap
            Asked 2021-Jan-22 at 11:23

            I'm trying to render some simple HTML/Bootstrap tables side by side but getting stuck at this even after trying the previous solutions offered from on here. I'm sure it's something simple but I'm new to this, so any help would be appreciated.

            I have two lists in my model, of equal size, that I would like to display beside each other. The correct data is being displayed, but I simply cannot get them to render alongside each other:

            //Layout

            ...

            ANSWER

            Answered 2021-Jan-22 at 11:23

            You have not added bootstrap class row. Wrap your code around div with class="row"

            Source https://stackoverflow.com/questions/65843988

            QUESTION

            Compiling vue-qrcode into razorlight and dinktopdf
            Asked 2020-Nov-29 at 07:39

            I'm working on building a POC where I compile an index.cshtml using razorlight then generate a pdf using dinktopdf, so far I got that part working fine.

            Next, using vuejs and vue-qrcode, I was able to add a qrcode to the page where qr-code tag is converted into canvas and the qrcode is being displayed.

            Now, the issue I'm running into is that during the generation of the pdf, vue-qrcode isn't being compiled into regular html (it should be a canvas tag) and nothing is being added to the pdf.

            The solution is in the following Repository

            page = await engine.CompileRenderAsync(path, model); shows the full string of the html and in there you can see the the qr-code tag still remains as it is.

            ...

            ANSWER

            Answered 2020-Nov-29 at 07:39

            I was able to solve the issue using pure JavaScript QRCode instead of vue-qrcode library.

            The final view

            Source https://stackoverflow.com/questions/65018768

            QUESTION

            Razor Page HTML Rendering via RazorLight.NetCore3 Template Key
            Asked 2020-Sep-10 at 09:51

            I have recently integrated this RazorLight package for Razor page rendering. While using I came to notice that there is a Template key that has to be defined. What actually this template key is and what it does?

            ...

            ANSWER

            Answered 2020-Sep-10 at 09:51

            What actually this template key is and what it does?

            If i use a different template, then should i use the same key or different?

            Each template should have a templateKey that is associated with it while we create a template from string, so that we can re-run the cached template with this key. And the templateKey should be unique.

            Source https://stackoverflow.com/questions/63824565

            QUESTION

            .NET Core Blazor Dynamically retreive html as string from Razor Page or Blazor Component
            Asked 2020-Sep-10 at 07:09

            I have a Razor Page (.cshtml) which is a PDF Template. Now i am required to retreive html as string from the page itself to Save it as a PDF file. In MVC, i could use IRazonEngine interface for the same. But in Blazor what can used to obtain this.

            Additionally, if i can use Blazor component instead of a Razor Page, how can i get the string of HTML?

            Please help!

            This is the sample Razor Page I have

            ...

            ANSWER

            Answered 2020-Sep-09 at 09:40

            I think this is not about blazor or mvc pages, but you can use RazorEngine.NetCore library to convert the cshtml and fill in the dynamic data using a model and retrieve the completed html.

            Here is a guide on how to do it: https://khalidabuhakmeh.com/generate-outputs-with-razor-engine-in-dotnet-core

            Github project: https://github.com/fouadmess/RazorEngine

            Here is a simple code which I have used in the past:

            Source https://stackoverflow.com/questions/63808467

            QUESTION

            Mixing .net Framework projects with .net Core projects (and languages) - System.IO.FileNotFoundException
            Asked 2019-Jun-07 at 18:12

            I have a solution in which most of the projects are VB.net projects which all target the .NET Framework 4.8. All of those specific projects compile properly and are running in production.

            I have added a C# project that targets .net standard 2.0. The primary reason for this particular project is to create a component that can process razor templates (given a model of course) in order to create output files using the RazorLight_wik8wz nuget package (I don't really care which package I use so long as I can render a razor template in memory because the output generated by the model/template pair may be persisted in different places in different cases).

            In theory, and based on my understanding, I should be able to reference and use a .net standard 2.0 library project from my other .net framework 4.8 projects. However, I can't seem to get this to work (even though everything compiles and runs).

            I've tried several different packages based on RazorLight--but I get similar results when I try to use them. I'm simply not sure if I'm encountering a bug or if I'm not doing something properly.

            The C# project is named "JobOutputGenerator." I have added the nuget package called "RazorLight_wik8wz" and created an object called JobOutput that currently looks like this:

            ...

            ANSWER

            Answered 2019-Jun-07 at 18:12

            So after more searches I came across the following problem and set of posts. Following this workaround seems to have solved my problem for now.

            Apparently this has been a problem for quite some time (since 2017--thanks Microsoft!) without a permanent fix.

            The problem was first reported here:

            NuGet dependencies of .NET Standard library referenced from classic .NET app cannot be resolved at runtime with FileNotFoundException #1582

            If you read through this string of messages, you eventually come to this workaround near the bottom, with others confirming this person's findings. Following this workaround causes the DLL files to all get built/copied to the Debug folder and now the referenced DLL is no longer "missing" and the exception I was receiving at runtime is gone.

            I made this modification to my JobOutputGenerator .csproj file, except that I used ;net48 instead of ;net461 .

            NOTE THE TAG:

            Source https://stackoverflow.com/questions/56485889

            QUESTION

            .NET Core 2.2 Render cshtml as string
            Asked 2019-Mar-29 at 05:43

            I have this cshtml file located in this path

            ...

            ANSWER

            Answered 2019-Mar-28 at 14:04

            Inject IHostingEnvironment and use _env.ContentRootPath:

            Source https://stackoverflow.com/questions/55399324

            QUESTION

            .Net Standard 2.0 CompilationLibrary.ResolveReferencePaths fails
            Asked 2019-Mar-14 at 14:34

            TL;DR; Is there anyway to tell CompilationLibrary.ResolveReferencePaths where to look for the references?

            I've tried modifying the current working directory and even tried modifying the current AppDomain base directory to no avail.

            So my team is currently using RazorLight to handle message templating in a .Net Core 2.2 console application.

            I have added RazorLight 2.0.0-beta1 to a .Net Standard 2.0 library and created an interface for it. However, we discovered there was a conflict with a different library we were using due to that library using a C DLL. To solve the conflict we opted to remove the other library using the C DLL as no one had been using it's functionality yet. However, now we are at a point where we need both.

            Luckily, RazorLight allows you to specify an assembly to use as the root. So I created a basic empty library project (RazorScope), that has no libraries other than RazorLight and our Models library.

            RazorScope has the PreserveCompilationContext flag to true in it's csproj.

            I have a pre-build event on our console app to publish RazorScope to the solution root/RazorScope folder and then a post-build and post-publish event that copies the RazorScope publish into the console app build/publish. I chose to go this route due to the "refs" folder that PreserveCompilationContext creates and I wanted to keep things clean. If I just add RazorScope as a project reference to the console application, it doesn't pull in those refs or the json.deps file for RazorScope...

            The issue is that when RazorLight eventually calls CompilationLibrary.ResolveReferencePaths, it fails b/c it refuses to look in the RazorScope folder in the bin/publish directory and expects everything to be directly in the base directory. If I move the refs and other files up to base, it works fine, but now I've dirtied my console task bin/publish directory.

            Is there anyway to tell CompilationLibrary.ResolveReferencePaths where to look for the references?

            ...

            ANSWER

            Answered 2019-Mar-14 at 14:34

            The answer to this is just to not use the RazorLightEngine Nuget package. It's not really being maintained regularly anyway.

            I ended up just rolling my own Roslyn compilation instance after using the .net core razor library to generate the c# code.

            Source https://stackoverflow.com/questions/55011587

            QUESTION

            Manually creating an HttpContext in ASP.NET Core 2.x
            Asked 2018-Dec-04 at 18:58

            I'm trying to render a Razor view to a string from a Hosted Service. By using the IRazorViewEngine I am able to render a view to a string using something like the following:

            ...

            ANSWER

            Answered 2018-Dec-04 at 03:39

            QUESTION

            Sending Newsletter using template .Net Core
            Asked 2018-Aug-23 at 16:25

            I have being tasked with setting up a way where an admin user can easily pick articles to send out to a list of subscribers. The below image is what i'm trying to create but my problem is how get the view sent in an email. I have it created as a static template and as a razor template. I tried to use RazorEngine and Razorlight but can't figure them out.

            Alot of the questions i have seen on this only adds one item to a email. e.g here and here. I am using MailKit to send emails but for the life of me i cant figure how to get an email body like above. My code looks like this

            ...

            ANSWER

            Answered 2018-Aug-23 at 16:25

            After a long time searching i cam across this answer which enabled my to get the answer i was looking for. First i add this code to my constructor

            Source https://stackoverflow.com/questions/51874142

            QUESTION

            Razor templates: Cannot find compilation library location for package
            Asked 2018-Jul-10 at 15:50

            I ran into this error with .NET Core 2.0 and .NET Core 2.1, while using RazorLight coupled with cshtml Razor template files for FluentEmail, in an ASP.NET Core app:

            "Cannot find compilation library location for package XYZ"

            Where XYZ seemed to change depending on what version of .NET Core I had deployed.

            The error did not present itself in my dev environment, but reared its head after deployment, when hitting any API endpoint that required FluentEmail to use the Razor template files to generate the email body.

            ...

            ANSWER

            Answered 2018-Jul-10 at 15:50

            Publish-time compilation of Razor files is enabled by default. In my case, I did not need this feature, because my Razor templates were being compiled by FluentEmail at runtime. By adding false to the app's csproj file, publish-time compilation was disabled, and the error resolved.

            Example csproj entry:

            Source https://stackoverflow.com/questions/51269559

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install RazorLight

            Install the nuget package using following command:. The simplest scenario is to create a template from string. Each template must have a templateKey that is associated with it, so you can render the same template next time without recompilation.

            Support

            Visual Studio tooling knows nothing about RazorLight and assumes, that the view you are using - is a typical ASP.NET MVC template. In order to enable Intellisense for RazorLight templates, you should give Visual Studio a little hint about the base template class, that all your templates inherit implicitly.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link