Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Fix for issue [Dust] Generated template doesn't work on Windows #3

Closed
wants to merge 2 commits into from

Conversation

leodagdag
Copy link

Hello,

It's my first pull-request, so I try to not make trouble.

This pull-request answers the issue I created. I closed it because it's a duplicate now.

This issue is related to https://groups.google.com/forum/?fromgroups&hl=fr#!searchin/play-framework/2.0$20dust/play-framework/2n4aYP45H6Q/Q3tE5YSlOJIJ

There is a little issue using it on Windows. The generated template looks like this :

(function(){dust.register("D:\dev\play-plugins\dust\sample\app\assets\example.tl",body_0);...

which doesn't work !

The mistake is in https://github.com/typesafehub/play-plugins/blob/master/dust/src/main/scala/com/typesafe/plugin/DustTasks.scala.
The last character added to assertDir is /, before replacement by "" which works on Linux/Mac but not on Windows ;)

val msg = compile(sourceFile.getPath.replace(assetsDir.getPath + "/", ""), IO.read(sourceFile)).left.map {
              case (msg, line, column) => throw AssetCompilationException(Some(sourceFile),
                msg,
                line,
                column)
            }.right.get

To fix this issue, I made 2 changes:

  1. Instead of hardcoding the replacement of assertDir + "/" by "", I drop the last character which is
    • on Linux/Mac a /
    • on Windows a </code>
  2. With the result, I replace all </code> by / to have a right path in case templates files are in a sub directory of asserts

And I move the example.tl file in assets/templates/ directory to test the case a template is not directly in asserts directory

I made the test on Windows, but unfortunately, I have no Linux or Mac environnement to test on them, i hope it works fine on all environnements

Have a nice day

F.

leodagdag added 2 commits April 7, 2012 17:44
I move the example.tl file in assets/templates/ directory to test the case
a template is not at the root of assets directory
@leodagdag
Copy link
Author

The second commit uses java.io.File.separator which is a better solution than using hard coded value.

F.

@pk11
Copy link
Contributor

pk11 commented Apr 11, 2012

could you please sign our cla? http://www.typesafe.com/contribute/cla

also could you please create a new pull request with only the second commit?

@leodagdag
Copy link
Author

Hello Peter,

I create a new pull request as you request
#8
and also signe CLA.

F.

@leodagdag leodagdag closed this Apr 11, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants