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

Set RegisterSafeType but render fails silently and no data is present. #129

uncled1023 opened this Issue Jan 15, 2015 · 1 comment


None yet
2 participants

uncled1023 commented Jan 15, 2015

Hello! I have set up a small template engine class to handle registering the classes and actually rendering the template with the data. My data has some custom classes as you will see.

Here is my template engine class:

public class TemplateEngine
        private Template _Template;
        private Controller _Controller;

        public TemplateEngine(Controller controller)
            _Controller = controller;
            Template.NamingConvention = new DotLiquid.NamingConventions.CSharpNamingConvention();
            Template.RegisterSafeType(typeof(Controller), new string[] { "Parameters", "GCode" });
            Template.RegisterSafeType(typeof(GCode), new string[] { "GCodeValid", "GCode", "FSPVT", "CO2PVT", "Feedrate" });
            Template.RegisterSafeType(typeof(PVT), new string[] { "Position", "Velocity", "Time", "ZStep" });
            Template.RegisterSafeType(typeof(PVTPoint), new string[] { "X", "Y", "C" });

        public string Compile()
            string compiledTemplate = string.Empty;

            string template = string.Empty;
            StreamReader streamReader = new StreamReader(_Controller.Parameters.TemplatePath);
            template = streamReader.ReadToEnd();

            _Template = Template.Parse(template);
            compiledTemplate = _Template.Render(Hash.FromAnonymousObject(new { Controller = _Controller }));

            return compiledTemplate;

And here is the template I am using:

Test Template.

{% for pvt in Controller.GCode.FSPVT -%}
    X{{ pvt.Position.X }} [{{ pvt.Velocity.X }}]
{% endfor -%}

The output I am getting is the following:

Test Template.


Any thoughts??


This comment has been minimized.

Show comment
Hide comment

haf Jul 22, 2016


No thoughts, sorry.


haf commented Jul 22, 2016

No thoughts, sorry.

@haf haf closed this Jul 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment