MTL templates without enabling string templates?
See original GitHub issueIs your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I’m always frustrated when […]
I want to use Manifold templates, but it pulls in a dependency on manifold-strings, which seems to automatically enable string interpolation in Java source files. All I’m looking for is a templating language, and MTL looks amazing. At this point, I’m not interested in adding string interpolation to all of my .java files.
I’m building a framework that will be extended by other teams, and I don’t want to ask each of these teams to either decorate all of their classes with manifold.strings.api.DisableStringLiteralTemplates
, escape $
found in every string, or implement the manifold.strings.api.ITemplateProcessorGate
SPI.
I don’t know if trusting all users of a framework to properly implement ITemplateProcessorGate
is going to scale either. To do it properly, you’d need to only ensure that you exclude files that are part of your own package rather than blanket excluding files from other packages you don’t own that might actually rely on string interpolation.
Describe the solution you’d like A clear and concise description of what you want to happen.
Ideally, I could use manifold-templates without needing to enable string interpolation in all of my source files. Maybe there’s a compiler setting to disable string interpolation except for when used in templates? Or maybe, you should have to explicitly enable string interpolation rather than disable it.
Describe alternatives you’ve considered A clear and concise description of any alternative solutions or features you’ve considered.
My idea for a workaround is to add an implementation of ITemplateProcessorGate
that only allows interpolation on type names ending with “Template”. I don’t think this is going to work 5 years from now if Manifold becomes mainstream and people start relying on string interpolation.
package com.foo.example;
import manifold.strings.api.ITemplateProcessorGate;
public class TemplateProcessorGate implements ITemplateProcessorGate {
@Override
public boolean exclude(String typeName) {
return !typeName.endsWith("Template");
}
}
Additional context Add any other context or screenshots about the feature request here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
@mtdowling
manifold-templates
will changemanifold-strings
to an optional dependency, which will hide it from your project. This change will be released later this week. Thanks for reporting this!@mtdowling Update. The change for this did not make it v2019.1.21. Now scheduled for release in v2019.1.23 within 10 days. Apologies for the delay.