Skip to content

Commit

Permalink
Allow for multiple renders to process a single file
Browse files Browse the repository at this point in the history
For example a file named 'myFile.md.vtl' would be first processed as a velocity template and then as markdown, resulting in 'myfile.html'
  • Loading branch information
bdemers committed Oct 22, 2016
1 parent 5307604 commit 741a178
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,20 +311,30 @@ class DefaultProcessor implements Processor {
String destRelPath = relPath; //assume same unless it is itself a template

Renderer renderer = getRenderer(config, destRelPath)
if (renderer) {

while (renderer) {

String extension = getExtension(destRelPath)
content = Files.newBufferedReader(f.toPath(), StandardCharsets.UTF_8)
destRelPath = relPath.substring(0, relPath.length() - (extension.length() + 1))
if (content == null) {
content = Files.newBufferedReader(f.toPath(), StandardCharsets.UTF_8)
}
destRelPath = destRelPath.substring(0, destRelPath.length() - (extension.length() + 1))

String destExtension = (renderer instanceof FileRenderer) ? renderer.outputFileExtension : extension;

if (config.outputFileExtension) {
destExtension = config.outputFileExtension
}

destRelPath += ".$destExtension"
Renderer nextRenderer = getRenderer(config, destRelPath)

// if this is the last renderer set the extension, otherwise, skip it
if (nextRenderer == null && !destRelPath.endsWith(".$destExtension")) {
destRelPath += ".$destExtension"
}

content = render(renderer, model, destRelPath, content)
renderer = nextRenderer
}

if (config.template) { //a template will be used to render the contents
Expand Down

0 comments on commit 741a178

Please sign in to comment.