question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MTL templates without enabling string templates?

See original GitHub issue

Is 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:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rsmckinneycommented, Aug 24, 2020

@mtdowling manifold-templates will change manifold-strings to an optional dependency, which will hide it from your project. This change will be released later this week. Thanks for reporting this!

1reaction
rsmckinneycommented, Oct 15, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded expressions, ...
Read more >
Nicer way to optionally include String in ES6 String template
I'm using ES6 String templates to try to make the syntax nicer than plain old string concatenation. However the best way I've found...
Read more >
Template Strings, String interpolation & multi-line Typescript
Template literals (Template strings) are multiline strings allowing embedded expressions, basic string formatting, string interpolation ...
Read more >
JEP 430: String Templates (Preview) - OpenJDK
Enable the creation of non-String expressions derived from combining literal text and embedded expressions, without having to transit through a ...
Read more >
Template literals (Template strings) - JavaScript
Template literals are string literals allowing embedded expressions. You can use multi-line strings and string interpolation features with them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found