Skip to content

Allow non-global template configuration - #94

Closed
rdumont wants to merge 9 commits into
dotliquid:masterfrom
rdumont:feature/non-global-configuration
Closed

rdumont wants to merge 9 commits into
dotliquid:masterfrom
rdumont:feature/non-global-configuration

Conversation

@rdumont

@rdumont rdumont commented Feb 18, 2014

Copy link
Copy Markdown
Member

Fixes #93. This is what I got:

Before

Template.RegisterFilter(typeof(SomeFilters)); // Filter registration
Template.RegisterValueTypeTransformer(type, func); // Value type transformer
Template.RegisterSafeType(type, allowedMembers); // Safe type
Template.RegisterTag<MyTag>("my");  // Tag registration
Template.FileSystem = new MyFileSystem(); // File system

Template.NamingConvention = new SomeNamingConvention();

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

After

var config = new TemplateConfiguration();
config.RegisterFilter(typeof(SomeFilters)); // Filter registration
config.RegisterValueTypeTransformer(type, func); // Value type transformer
config.RegisterSafeType(type, allowedMembers); // Safe type
config.RegisterTag<MyTag>("my");  // Tag registration
config.FileSystem = new MyFileSystem(); // File system

Template.NamingConvention = new SomeNamingConvention(); // The naming convention was kept global for now, since it could too heavily impact performance and caching

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

The global methods were all kept so that it doesn't break the interface. Also, the syntax for each configuration was kept the same (including overloads), except for being on the TemplateConfiguration instance.

I ran performance tests and no difference was detected on the time taken to run all the tests. Is this good to go?

Motivation

In case anyone fails to understand the importance of this feature, here is my real-world scenario.

1. Support different schemas: I have different schemas of my application running at the same time on the same application. Each schema supports completely different structures for the entities and have tags with different behaviors, although both run on DotLiquid. Therefore, I need to be able to conditionally use a different DotLiquid configuration for each schema.

2. Validation: My application supports editing entities through a REST API, so I need to validate their contents so that they don't break at run time. I've found that the best way to do this is by registering fake tags that, instead of fully running their production code, just verify the integrity of their contents and configuration.

3. Testing: I don't want my unit tests to depend on a global, static, configuration. If I am testing a class, the test configuration should be as isolated and as close to my tests as possible.

@rdumont

rdumont commented May 14, 2014

Copy link
Copy Markdown
Member Author

@tgjones could you please have a look at this? This PR introduces very small changes to many files, so it is very prone to having merge conflicts. The sooner you can merge it (that is if you decide to do so), the less conflicts there will be.

@tgjones

tgjones commented May 15, 2014

Copy link
Copy Markdown
Contributor

@rdumont This is a tough one. Firstly, I do like these changes - introducing a non-global API is definitely the direction I want to go in with DotLiquid. And I appreciate the amount of work you put it in to prepare this pull request.

But... I was planning to move to a non-global API (only, without the existing global API) as part of v2.0, and the new major version number would allow it to be backwards-incompatible (with appropriate documentation for helping users move from v1.x to v2.0). Being free from backwards-compatibility concerns would help with the refactoring.

My preference is to break it good, and make these changes as part of a wider refactoring that will become v2.0. That said, I think this pull request could be a good starting point, so I'm going to leave it open for now, and possibly merge it in when I start working on v2.0 (your TemplateConfiguration class is quite close to what I was thinking about too).

I'm aware I haven't been able to put much time into DotLiquid in recent months, but I'm hoping that will change in the near future.

I notice that at least one of your commits (770c228) is for a different issue, please could you open a new pull request for that one?

@tgjones

tgjones commented May 15, 2014

Copy link
Copy Markdown
Contributor

(Apart from a non-global API, the other big feature I want to do in v2.0 is a proper parser, instead of the current regex-based one. Something similar-ish to Shopify/liquid#235)

@rdumont

rdumont commented May 15, 2014

Copy link
Copy Markdown
Member Author

@tgjones thanks for the reply! I'm really happy to know that you are thinking of this new major and what you said makes total sense. This feature will be better off in it. You can count me in too to help with the job of making 2.0. The new parser idea is also very good.

I will open another PR for the tests correction ASAP!

@tgjones

tgjones commented May 15, 2014

Copy link
Copy Markdown
Contributor

Great, thank you - once I've got a clearer idea of how (and when) to proceed with v2.0, I'll try to create some sort of plan so that those who are interested can tackle discrete bits of work.

@ghost

ghost commented Dec 15, 2014

Copy link
Copy Markdown

@tgjones Any update on the plan for v2.0?

@tgjones

tgjones commented Dec 15, 2014

Copy link
Copy Markdown
Contributor

I'm feeling a lot of open source guilt about DotLiquid v2 - and DotLiquid in general.

On the one hand, I haven't used DotLiquid myself for a long time. I've been steadily answering StackOverflow questions about DotLiquid, answering (usually belatedly, admittedly) questions on the Google Group, reviewing pull requests and bug fixes, and doing a few releases on NuGet. That is neither more nor less than what I should do, as the project owner / maintainer. But aside from the satisfaction of running a reasonably successful OSS project, there isn't a great deal of upside for me - I no longer use DotLiquid myself. And it takes a lot longer to answer questions and fix bugs than people might imagine :)

On the other hand, I do have a vision for DotLiquid's future, some of which I outlined above. I want to keep DotLiquid's core strengths intact - safe by default, well tested, and trusted by its users - while moving to a more modern API based around a proper compiler and non-static configuration.

But I'm coming to the conclusion that I'm not going to be able to invest the time to do that work myself. One possible route forward is:

  • I've already created the dotliquid organisation here on GitHub. I'd like to move the DotLiquid repository to that organisation, in preparation for it becoming more of a community project.
  • If somebody - or even 2 or 3 people - is / are willing to become core contributors, and who can demonstrate or have already demonstrated a commitment to keeping the good parts of DotLiquid intact, then I'd be willing to cede some control over the project. I'll still remain as one of the core contributors, but other core contributors would be able to make changes without my prior approval.
  • There are a number of existing issues and pull requests that could be fixed / merged in the 1.x line. Those are the highest priority tasks. Once one or more core contributors are on board, they'd be able to help with this.
  • After that, v2.0 - and perhaps this very pull request could form the basis of it. That would be up to the core contributors. I would be around to offer guidance - and perhaps write a checklist of desirable features for v2.0 - but I probably won't be writing much code.

It's difficult to consider giving up control, because... well, I'm a bit of a control freak. But I also want to see DotLiquid thrive, so I think this is a necessary direction to go in.

I'd be grateful if people would weigh in here with their opinions about this.

@petrhaus

Copy link
Copy Markdown
Member

Count me in, but only if you maintain control.
Although I don't have much time to dedicate to contributing the project, my
company has used it and is actually planning usage for new projects.
I can spend time on pull requests and review, and hope someone is going to
take on for a 2.0 release.

Thanks!

AP

On Mon, Dec 15, 2014 at 3:38 PM, Tim Jones [email protected] wrote:

I'm feeling a lot of open source guilt
https://signalvnoise.com/posts/3349-open-source-guilt-passion about
DotLiquid v2 - and DotLiquid in general.

On the one hand, I haven't used DotLiquid myself for a long time. I've
been steadily answering StackOverflow questions about DotLiquid, answering
(usually belatedly, admittedly) questions on the Google Group, reviewing
pull requests and bug fixes, and doing a few releases on NuGet. That is
neither more nor less than what I should do, as the project owner /
maintainer. But aside from the satisfaction of running a reasonably
successful OSS project, there isn't a great deal of upside for me - I no
longer use DotLiquid myself.

On the other hand, I do have a vision for DotLiquid's future, some of
which I outlined above
#94 (comment).
I want to keep DotLiquid's core strengths intact - safe by default, well
tested, and trusted by its users - while moving to a more modern API based
around a proper compiler and non-static configuration.

But I'm coming to the conclusion that I'm not going to be able to invest
the time to do that work myself. One possible route forward is:

I've already created the dotliquid https://github.com/dotliquid
organisation here on GitHub. I'd like to move the DotLiquid repository to
that organisation, in preparation for it becoming more of a community
project.

If somebody - or even 2 or 3 people - is / are willing to become core
contributors, and who can demonstrate or have already demonstrated a
commitment to keeping the good parts of DotLiquid intact, then I'd be
willing to cede some control over the project. I'll still remain as one of
the core contributors, but other core contributors would be able to make
changes without my prior approval.

There are a number of existing issues and pull requests that could be
fixed / merged in the 1.x line. Those are the highest priority tasks. Once
one or more core contributors are on board, they'd be able to help with
this.

After that, v2.0 - and perhaps this very pull request could form the
basis of it. That would be up to the core contributors. I would be around
to offer guidance - and perhaps write a checklist of desirable features for
v2.0 - but I probably won't be writing much code.

It's difficult to consider giving up control, because... well, I'm a bit
of a control freak. But I also want to see DotLiquid thrive, so I think
this is a necessary direction to go in.

I'd be grateful if people would weigh in here with their opinions about
this.

—
Reply to this email directly or view it on GitHub
#94 (comment).

@tgjones

tgjones commented Dec 16, 2014

Copy link
Copy Markdown
Contributor

Awesome, thanks Alessandro.

I guess the first step is to move the dotliquid repo to the dotliquid organisation. From what I've read here, the best option is to transfer ownership from the formosatek organisation to the dotliquid organisation. That way, GitHub will redirect git requests. Anyone have any experience with doing that? Does that sound like a sensible approach?

@rdumont

rdumont commented Dec 16, 2014

Copy link
Copy Markdown
Member Author

@tgjones I would love to get my hands dirty and help with the 2.0 release. Guidance and feature requests are all very welcome so we can make this happen.

I also agree that moving to the https://github.com/dotliquid organisation would be the best direction to take. You can count me in!

@petrhaus

Copy link
Copy Markdown
Member

Yes Tim, the most appropriate way is to transfer ownership between
organizations.

AP

On Tue, Dec 16, 2014 at 4:53 PM, Tim Jones [email protected] wrote:

Awesome, thanks Alessandro.

I guess the first step is to move the dotliquid repo to the dotliquid
organisation. From what I've read here
https://help.github.com/articles/transferring-a-repository/, the best
option is to transfer ownership from the formosatek organisation to the
dotliquid organisation. That way, GitHub will redirect git requests. Anyone
have any experience with doing that? Does that sound like a sensible
approach?

—
Reply to this email directly or view it on GitHub
#94 (comment).

@tgjones

tgjones commented Dec 17, 2014

Copy link
Copy Markdown
Contributor

Thank you Rodrigo - that's great!

I'll move the repo now, fingers crossed...

@tgjones

tgjones commented Dec 17, 2014

Copy link
Copy Markdown
Contributor

Done - looks okay to me. The HTTP redirect is working. I haven't tested the Git redirect, but presumably that's working too. Welcome to your new home, dotliquid...

@mathieukempe

Copy link
Copy Markdown

Count me in! I'd be happy to help with version 2.0.

@tgjones

tgjones commented Dec 19, 2014

Copy link
Copy Markdown
Contributor

Thank you, Mathieu, that's great!

In the meantime, there are a number of open issues and pull requests that shouldn't be breaking changes, and can be pulled into 1.x.

I won't pollute this pull request anymore; let's move the discussion to Gitter:

https://gitter.im/dotliquid/dotliquid

Thanks!

On 18 Dec 2014, at 07:34, Mathieu Kempe [email protected] wrote:

Count me in! I'd be happy to help with version 2.0.

—
Reply to this email directly or view it on GitHub.

@haf

haf commented Jul 22, 2016

Copy link
Copy Markdown
Contributor

Closing due to lack of activity.

@axm

axm commented Dec 8, 2018

Copy link
Copy Markdown

This never got in, right? Because I'd like to see something like it and I'm happy to implement it.

@haf

haf commented Dec 9, 2018

Copy link
Copy Markdown
Contributor

@axm Correct, feel free to have a go at it

@axm

axm commented Dec 9, 2018

Copy link
Copy Markdown

@haf All right

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow non-global template configuration

6 participants