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

Move TemplateEngine into FreeMarker implementation #230

Merged
merged 1 commit into from
Dec 13, 2019

Conversation

mtdowling
Copy link
Member

The TemplateEngine code in smithy-codegen-core was created with the
intention of making a standard interface for integrating Smithy with
different template engines. However, over time we've moved away from
template engines and more towards using SymbolProviders and custom
CodeWriter implementations.

This commit moves the TemplateEngine code into the FreeMarkerEngine directly,
and depreacates the DefaultDataTemplateEngine. Future template integrations
with Smithy should expose their own APIs, and really should only be
used/created for cases where the CodeWriter can't be used.

The biggest motivation for moving away from template engines and towards
CodeWriter is that templates for code generation often require a great
deal of logic, making templates a poor substitute for programming
languages, and template engines usually require a data model. However,
Smithy provides a great deal of libraries and APIs that already function
as a more than adequate data model, making the explicit creation of a
static data model (like in the case of Mustache or FreeMarker), more of
an excercise in making the template engine happy than in functionality.
Template engines like MTL and Rocker don't suffer from this since they
generate Java code directly and allow embedded Java code, but their use
would only further justify the remove of a standard TemplateEngine
interface since they require a typed list of arguments to invoke an
actual Java method.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

The TemplateEngine code in smithy-codegen-core was created with the
intention of making a standard interface for integrating Smithy with
different template engines. However, over time we've moved away from
template engines and more towards using SymbolProviders and custom
CodeWriter implementations.

This commit moves the TemplateEngine code into the FreeMarkerEngine directly,
and depreacates the DefaultDataTemplateEngine. Future template integrations
with Smithy should expose their own APIs, and really should only be
used/created for cases where the CodeWriter can't be used.

The biggest motivation for moving away from template engines and towards
CodeWriter is that templates for code generation often require a great
deal of logic, making templates a poor substitute for programming
languages, and template engines usually require a data model. However,
Smithy provides a great deal of libraries and APIs that already function
as a more than adequate data model, making the explicit creation of a
static data model (like in the case of Mustache or FreeMarker), more of
an excercise in making the template engine happy than in functionality.
Template engines like MTL and Rocker don't suffer from this since they
generate Java code directly and allow embedded Java code, but their use
would only further justify the remove of a standard TemplateEngine
interface since they require a typed list of arguments to invoke an
actual Java method.
@mtdowling mtdowling merged commit db5722a into master Dec 13, 2019
@mtdowling mtdowling deleted the deprecate-template-engine-abstraction branch December 13, 2019 18:23
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.

2 participants