Created
August 8, 2012 04:57
-
-
Save chkal/3292206 to your computer and use it in GitHub Desktop.
Using Jade with Rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JadeTransformer extends StringTransformer | |
{ | |
@Override | |
public String transform(String src) | |
{ | |
try { | |
return new Jade().process(src, new HashMap<String, Object>()); | |
} | |
catch (IOException e) { | |
throw new IllegalStateException(e); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyConfigProvider extends HttpConfigurationProvider | |
{ | |
@Override | |
public int priority() | |
{ | |
return 0; | |
} | |
@Override | |
public Configuration getConfiguration(final ServletContext context) | |
{ | |
return ConfigurationBuilder.begin() | |
.addRule() | |
.when(Path.matches("/{something}.html")) | |
.perform(Forward.to("/{something}.jade").and(Transform.with(JadeTransformer.class))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment