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

PartialCode dir is looking for last hard-coded forward-slash in Windows OS #296

Open
PietroIaia opened this issue Oct 4, 2023 · 1 comment

Comments

@PietroIaia
Copy link

At constructor of PartialCode.java, in line 23, the slash it looks for is hard-coded to be forward-slash (Used everywhere except Windows):

protected PartialCode(TemplateContext tc, DefaultMustacheFactory df, Mustache mustache, String type, String variable) {
    super(tc, df, mustache, variable, type);

    // Use the  name of the parent to get the name of the partial
    String file = tc.file();
    int dotindex = file.lastIndexOf(".");
    extension = dotindex == -1 ? "" : file.substring(dotindex);
    int slashindex = file.lastIndexOf("/");    <------------------------------ line 23
    dir = file.substring(0, slashindex + 1);
    recrusionLimit = df.getRecursionLimit();
}

When running on Windows OS, the file's path is usually stored using back-slashes and .lastIndexOf("/") will fail to find the correct index.

@spullara
Copy link
Owner

spullara commented Oct 9, 2023

Inside the templates you should only use forward slashes (to make them work cross platform). Is there another way that this gets populated such that a backslash might appear?

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

No branches or pull requests

2 participants