Skip to content

Allow non-global template configuration #93

Closed

Description

@rdumont

This proposal is intended to provide a way to use multiple rendering configurations in an application, so that you don't have to use the global tag/filter/safe type/naming convention/file system configuration.

Currently template configuration is done as follows:

Template.RegisterTag<MyTag>("my");
Template.NamingConvention = new CSharpNamingConvention();
// etc.

var template = Template.Parse("some template text");
var result = template.Render();

My intention is to allow the following syntax, while keeping the former for compatibility and simplicity for those who only need global registration.

var config = new LiquidConfiguration();
config.RegisterTag<MyTag>("my");
config.NamingConvention = new CSharpNamingConvention();
// etc.

var template = Template.Parse("some template text", config);
var result = template.Render();

I also thing it would be interesting to provide a more fluent configuration, such as:

var config = new LiquidConfiguration()
    .RegisterTag<MyTag>("my")
    .SetNamingConvention(new CSharpNamingConvention());

Any ideas? I intend on sending a pull request ASAP.

Activity

  1. haf commented on Jul 22, 2016

    @haf
    Contributor

    The solution to this is to rebase #94 so that I can merge it.

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

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