Skip to content

Fluid usage recommendations #136

@sebastienros

Description

@sebastienros

Here is a snippet of the template rendering

var options = new TemplateOptions();
options.CultureInfo = System.Globalization.CultureInfo.CurrentUICulture;
options.MemberAccessStrategy = new UnsafeMemberAccessStrategy();

var context = new TemplateContext(model, options, allowModelMembers: true);

var template = _fluidParser.Parse(source);
return template.Render(context);

TemplateOptions should be reused. It is expensive to create new instances as caches are not reused. Register this as a singleton.

Template results from Parse should be reused. If the same templates are parsed then it makes sense to create a local cache of the parsed templates. A simple dictionary based on the source, or a key derived from it (filename, timestamp, ...) in a constrained IMemoryCache (time and size bound), would be ideal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions