Giter VIP home page Giter VIP logo

Comments (8)

adoconnection avatar adoconnection commented on August 17, 2024
using System;
using RazorEngineCore;

namespace ConsoleApp44
{
    class Program
    {
        static void Main(string[] args)
        {
            RazorEngine engine = new RazorEngine();

            IRazorEngineCompiledTemplate razorEngineCompiledTemplate = engine.Compile(@"
                @if (true) {
                var test=1;
                }
            ");

            Console.WriteLine(razorEngineCompiledTemplate.Run());
            Console.ReadKey();
        }
    }
}

looks ok to me

from razorenginecore.

kobruleht avatar kobruleht commented on August 17, 2024

Try without if:

 @{
             var test=1;
                }

from razorenginecore.

adoconnection avatar adoconnection commented on August 17, 2024

same output

namespace ConsoleApp44
{
    class Program
    {
        static void Main(string[] args)
        {
            RazorEngine engine = new RazorEngine();

            IRazorEngineCompiledTemplate razorEngineCompiledTemplate = engine.Compile(@"
                 @{
             var test=1;
                }
            ");

            Console.WriteLine("start");
            Console.WriteLine(razorEngineCompiledTemplate.Run());
            Console.WriteLine("end");
            Console.ReadKey();
        }
    }
}

image

from razorenginecore.

kobruleht avatar kobruleht commented on August 17, 2024

Please try

<img src='@("test")'>

output is without trailing ' :

<img src='test>

from razorenginecore.

adoconnection avatar adoconnection commented on August 17, 2024

could you please submit it a way of console app code, like I do. It will make reproducing a lot easier

from razorenginecore.

kobruleht avatar kobruleht commented on August 17, 2024

Code:

using System;
using System.Threading.Tasks;
using RazorEngineCore;

namespace SampleApp
{
    public class Program
    {
        static async Task Main(string[] args)
        {
            RazorEngine razorEngine = new RazorEngine();
            var template =
                await razorEngine.CompileAsync<RazorEngineCorePageModel>(
                    @"<img href='@(""test"")'>");
            var res = await template.RunAsync();
            // Observed: trailing ' is lost
            Console.WriteLine(res);
            Console.ReadKey();
        }
    }
}

Project:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="RazorEngineCore" Version="2021.3.1" />
    <PackageReference Include="RazorEngineCore.Extensions" Version="0.3.0" />
  </ItemGroup>

</Project>

from razorenginecore.

kobruleht avatar kobruleht commented on August 17, 2024

Without RazorEngineCore.Extensions package it works OK .

RazorEngineCore.Extensions provides encoding and Html helper which are used for Html rendering. RazorEngineCore.Extensions seems dead. Why not to add using html encoding by default and Html helper from it to RazorEngineCore.

from razorenginecore.

wdcossey avatar wdcossey commented on August 17, 2024

@adoconnection this is resolved on my end, you can close this issue.

from razorenginecore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.