blob: ef7a59f1cbd13c450b7b435446c0cbd5692ff955 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package dotty.tools
package dottydoc
package staticsite
import dotc.config.Printers.dottydoc
case class LiquidTemplate(contents: String) extends ResourceFinder {
import scala.collection.JavaConverters._
import liqp.Template
import liqp.filters.Filter
import liqp.parser.Flavor.JEKYLL
import java.util.{ HashMap, Map => JMap }
import filters._
import tags._
/** Register filters to static container */
Filter.registerFilter(new Reverse)
Filter.registerFilter(new First)
// For some reason, liqp rejects a straight conversion using `.asJava`
private def toJavaMap(map: Map[String, AnyRef]): HashMap[String, Object] =
map.foldLeft(new HashMap[String, Object]()) { case (map, (k, v)) =>
map.put(k, v)
map
}
def render(params: Map[String, AnyRef], includes: Map[String, String]): String =
Template.parse(contents, JEKYLL)
.`with`(ResourceInclude(params, includes))
.`with`(RenderReference(params))
.`with`(RenderTitle(params))
.render(toJavaMap(params))
}
|