Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on parse when html attribute value templated #5

Closed
kae opened this issue Aug 12, 2016 · 2 comments
Closed

Exception on parse when html attribute value templated #5

kae opened this issue Aug 12, 2016 · 2 comments
Labels

Comments

@kae
Copy link

kae commented Aug 12, 2016

repro

using Microsoft.Extensions.PlatformAbstractions;

namespace ConsoleApplication {
    public class Program {
        public static void Main(string[] args) {
            var engine =
                RazorLight.EngineFactory.CreatePhysical(
                    PlatformServices.Default.Application.ApplicationBasePath
                );
            try {
                System.Console.WriteLine(
                    engine.Parse(
                        "Template.cshtml",
                        new TemplateModel {
                            Source = "test",
                            Text = "text"
                        }
                    )
                );
            }
            catch (RazorLight.TemplateCompilationException e) {
                foreach (var item in e.CompilationErrors) {
                    System.Console.WriteLine(item);
                }
            }
        }
    }
    public class TemplateModel {
        public string Source { get; set; }
        public string Text { get; set; }
    }
}

Template.cshtml

<html>
<body>
    <p>
        <a href="@Model.Source">@Model.Text</a>
    </p>
</body>
</html>

project.json

{
    "version": "1.0.0-*",
    "buildOptions": {
        "emitEntryPoint": true,
        "preserveCompilationContext": true,
        "copyToOutput": [
            "Template.cshtml"
        ]
    },
    "dependencies": {
        "Microsoft.Extensions.PlatformAbstractions": "1.0.0",
        "RazorLight": "1.0.0-beta2"
    },
    "frameworks": {
        "netcoreapp1.0": {
            "dependencies": {
                "Microsoft.NetCore.App": {
                    "type": "platform",
                    "version": "1.0.0"
                }
            }
        }
    }
}

Errors:

The name 'BeginWriteAttribute' does not exist in the current context
The name 'WriteAttributeValue' does not exist in the current context
The name 'EndWriteAttribute' does not exist in the current context

No issues when @Model.Source removed from template

@toddams toddams added the bug label Aug 12, 2016
@toddams
Copy link
Owner

toddams commented Aug 12, 2016

Thank you for your report, I'm working on the fix

@toddams
Copy link
Owner

toddams commented Aug 12, 2016

I fixed the bug, but will roll the update l8r because I'm also busy with #7

@toddams toddams closed this as completed Aug 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants