org.fusesource.scalate

TemplateEngine

class TemplateEngine extends AnyRef

A TemplateEngine is used to compile and load Scalate templates. The TemplateEngine takes care of setting up the Scala compiler and caching compiled templates for quicker subsequent loads of a requested template.

The TemplateEngine uses a workingDirectory to store the generated scala source code and the bytecode. By default this uses a dynamically generated directory. You can configure this yourself to use whatever directory you wish. Or you can use the scalate.workdir system property to specify the workingDirectory

Source
TemplateEngine.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. TemplateEngine
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by any2stringfmt
  3. by any2ArrowAssoc
  4. by any2Ensuring
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TemplateEngine(sourceDirectories: Traversable[File] = ..., mode: String = ...)

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. def +(other: String): String

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to StringAdd performed by method any2stringadd in scala.Predef.
    Definition Classes
    StringAdd
  5. def ->[B](y: B): (TemplateEngine, B)

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to ArrowAssoc[TemplateEngine] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  8. var allowCaching: Boolean

    Set to false if you don't want the template engine to ever cache any of the compiled templates.

    Set to false if you don't want the template engine to ever cache any of the compiled templates.

    If not explicitly configured this property can be configured using the scalate.allowCaching system property

  9. var allowReload: Boolean

    If true, then the template engine will check to see if the template has been updated since last compiled so that it can be reloaded.

    If true, then the template engine will check to see if the template has been updated since last compiled so that it can be reloaded. Defaults to true. YOu should set to false in production environments since the templates should not be changing.

    If not explicitly configured this property can be configured using the scalate.allowReload system property

  10. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  11. var bindings: List[Binding]

    By default lets bind the context so we get to reuse its methods in a template

  12. def boot(): Unit

  13. var bootClassName: String

  14. var bootInjections: List[AnyRef]

  15. def buildSourceMap(stratumName: String, uri: String, scalaFile: File, positions: TreeMap[OffsetPosition, OffsetPosition]): String

    Attributes
    protected
  16. def bytecodeDirectory: File

  17. def cacheHits: Int

    The number of times a template load request was serviced from the cache.

  18. def cacheMisses: Int

    The number of times a template load request could not be serviced from the cache and was loaded from disk.

  19. def canLoad(uri: String, extraBindings: Traversable[Binding]): Boolean

    Returns true if the URI can be loaded as a template

  20. def canLoad(uri: String): Boolean

    Returns true if the URI can be loaded as a template

  21. def canLoad(source: TemplateSource, extraBindings: Traversable[Binding] = Nil): Boolean

    Returns true if the URI can be loaded as a template

  22. def classFileName(uri: String): File

    Attributes
    protected
  23. var classLoader: ClassLoader

  24. var classpath: String

  25. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. var codeGenerators: Map[String, CodeGenerator]

    The supported template engines and their default extensions

  27. var combinedClassPath: Boolean

    Whether a custom classpath should be combined with the deduced classpath

  28. def compile(source: TemplateSource, extraBindings: Traversable[Binding] = Nil): Template

    Compiles a template source without placing it in the template cache.

    Compiles a template source without placing it in the template cache. Useful for temporary templates or dynamically created template

  29. def compileMoustache(text: String, extraBindings: Traversable[Binding] = Nil): Template

    Compiles the given Moustache template text and returns the template

  30. def compileScaml(text: String, extraBindings: Traversable[Binding] = Nil): Template

    Compiles the given SSP template text and returns the template

  31. def compileSsp(text: String, extraBindings: Traversable[Binding] = Nil): Template

    Compiles the given SSP template text and returns the template

  32. def compileText(extension: String, text: String, extraBindings: Traversable[Binding] = Nil): Template

    Compiles the given text using the given extension (such as ssp or scaml for example to denote what parser to use) and return the template

  33. lazy val compiler: Compiler

  34. var compilerInitialized: Boolean

  35. def createCompiler: Compiler

    Factory method to create a compiler for this TemplateEngine.

    Factory method to create a compiler for this TemplateEngine. Override if you wish to contorl the compilation in a different way such as in side SBT or something.

    Attributes
    protected
  36. def createRenderContext(uri: String, out: PrintWriter): RenderContext

    Factory method used by the layout helper methods that should be overloaded by template engine implementations if they wish to customize the render context implementation

    Factory method used by the layout helper methods that should be overloaded by template engine implementations if they wish to customize the render context implementation

    Attributes
    protected
  37. def ensuring(cond: (TemplateEngine) ⇒ Boolean, msg: ⇒ Any): TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to Ensuring[TemplateEngine] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  38. def ensuring(cond: (TemplateEngine) ⇒ Boolean): TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to Ensuring[TemplateEngine] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  39. def ensuring(cond: Boolean, msg: ⇒ Any): TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to Ensuring[TemplateEngine] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  40. def ensuring(cond: Boolean): TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to Ensuring[TemplateEngine] performed by method any2Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  41. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  42. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  43. var escapeMarkup: Boolean

    Whether or not markup sensitive characters for HTML/XML elements like & > < are escaped or not

  44. def expireAndCompile(source: TemplateSource, extraBindings: Traversable[Binding] = Nil): Unit

    Expire specific template source and then compile and cache again

  45. def extension(source: TemplateSource): Option[String]

    Extracts the extension from the source's uri though derived engines could override this behaviour to auto default missing extensions or performing custom mappings etc.

    Extracts the extension from the source's uri though derived engines could override this behaviour to auto default missing extensions or performing custom mappings etc.

    Attributes
    protected
  46. var extensionToTemplateExtension: Map[String, Set[String]]

    Maps file extensions to possible template extensions for custom mappins such as for Map("js" -> Set("coffee"), "css" => Set("sass", "scss"))

  47. def extensions: Set[String]

    Returns the file extensions understood by Scalate; all the template engines and pipelines including the wiki markup languages.

  48. def filter(name: String): Option[Filter]

  49. var filters: Map[String, Filter]

  50. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  51. val finderCache: ConcurrentHashMap[String, String]

  52. def formatted(fmtstr: String): String

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to StringFormat performed by method any2stringfmt in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @inline()
  53. def generateScala(uri: String): Code

    Generates the Scala code for a template.

    Generates the Scala code for a template. Useful for generating scala code that will then be compiled into the application as part of a build process.

  54. def generateScala(uri: String, extraBindings: Traversable[Binding]): Code

    Generates the Scala code for a template.

    Generates the Scala code for a template. Useful for generating scala code that will then be compiled into the application as part of a build process.

  55. def generateScala(source: TemplateSource, extraBindings: Traversable[Binding] = Nil): Code

    Generates the Scala code for a template.

    Generates the Scala code for a template. Useful for generating scala code that will then be compiled into the application as part of a build process.

  56. def generator(source: TemplateSource): CodeGenerator

    Gets the code generator to use for the give uri string by looking up the uri's extension in the the codeGenerators map.

    Gets the code generator to use for the give uri string by looking up the uri's extension in the the codeGenerators map.

    Attributes
    protected
  57. def generatorForExtension(extension: String): CodeGenerator

    Returns the code generator for the given file extension

    Returns the code generator for the given file extension

    Attributes
    protected
  58. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  59. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  60. var importStatements: List[String]

    Sets the import statements used in each generated template class

  61. def invalidateCachedTemplates(): Boolean

    Invalidates all cached Templates.

  62. def isDevelopmentMode: Boolean

    Returns true if this template engine is being used in development mode.

  63. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  64. def layout(source: TemplateSource, context: RenderContext): Unit

    Renders the given template source using the current layoutStrategy

  65. def layout(source: TemplateSource, context: RenderContext, extraBindings: Traversable[Binding]): Unit

    Renders the given template source using the current layoutStrategy

  66. def layout(source: TemplateSource, attributes: Map[String, Any]): String

    Renders the given template source using the current layoutStrategy

  67. def layout(source: TemplateSource): String

    Renders the given template source using the current layoutStrategy

  68. def layout(uri: String, template: Template): String

  69. def layout(uri: String, context: RenderContext): Unit

  70. def layout(uri: String, template: Template, attributes: Map[String, Any]): String

    Renders the given template returning the output

  71. def layout(uri: String, template: Template, out: PrintWriter, attributes: Map[String, Any]): Unit

    Attributes
    protected
  72. def layout(uri: String, out: PrintWriter, attributes: Map[String, Any]): Unit

  73. def layout(uri: String, attributes: Map[String, Any] = Map(), extraBindings: Traversable[Binding] = Nil): String

    Renders the given template URI returning the output

  74. def layout(template: Template, context: RenderContext): Unit

    Renders the given template using the current layoutStrategy

  75. def layout(uri: String, context: RenderContext, extraBindings: Traversable[Binding]): Unit

    Renders the given template URI using the current layoutStrategy

  76. def layoutAsNodes(uri: String, template: Template): NodeSeq

  77. def layoutAsNodes(uri: String, template: Template, attributes: Map[String, Any]): NodeSeq

    Renders the given template returning the output

  78. def layoutAsNodes(uri: String, attributes: Map[String, Any] = Map(), extraBindings: Traversable[Binding] = Nil): NodeSeq

    Renders the given template URI returning the output

  79. var layoutStrategy: LayoutStrategy

  80. def libraryDirectory: File

  81. def load(uri: String): Template

    Compiles and then caches the specified template.

    Compiles and then caches the specified template. If the template was previously cached, the previously compiled template instance is returned. The cache entry in invalidated and then template is re-compiled if the template file has been updated since it was last compiled.

  82. def load(uri: String, extraBindings: Traversable[Binding]): Template

    Compiles and then caches the specified template.

    Compiles and then caches the specified template. If the template was previously cached, the previously compiled template instance is returned. The cache entry in invalidated and then template is re-compiled if the template file has been updated since it was last compiled.

  83. def load(file: File): Template

    Compiles and then caches the specified template.

    Compiles and then caches the specified template. If the template was previously cached, the previously compiled template instance is returned. The cache entry in invalidated and then template is re-compiled if the template file has been updated since it was last compiled.

  84. def load(file: File, extraBindings: Traversable[Binding]): Template

    Compiles and then caches the specified template.

    Compiles and then caches the specified template. If the template was previously cached, the previously compiled template instance is returned. The cache entry in invalidated and then template is re-compiled if the template file has been updated since it was last compiled.

  85. def load(source: TemplateSource, extraBindings: Traversable[Binding] = Nil): Template

    Compiles and then caches the specified template.

    Compiles and then caches the specified template. If the template was previously cached, the previously compiled template instance is returned. The cache entry in invalidated and then template is re-compiled if the template file has been updated since it was last compiled.

  86. var mode: String

  87. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  88. final def notify(): Unit

    Definition Classes
    AnyRef
  89. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  90. var packagePrefix: String

  91. def pipeline(source: TemplateSource): Option[List[Filter]]

    Gets a pipeline to use for the give uri string by looking up the uri's extension in the the pipelines map.

    Gets a pipeline to use for the give uri string by looking up the uri's extension in the the pipelines map.

    Attributes
    protected
  92. var pipelines: Map[String, List[Filter]]

  93. var resourceLoader: ResourceLoader

    Loads resources such as the templates based on URIs

  94. def shutdown(): Unit

  95. def source(uri: String, templateType: String): TemplateSource

    Returns a template source of the given type of template for the given URI and current resourceLoader

  96. def source(uri: String): TemplateSource

    Returns a template source for the given URI and current resourceLoader

  97. var sourceDirectories: Traversable[File]

  98. def sourceDirectoriesForwarder: TraversableForwarder[File]

    A forwarder so we can refer to whatever the current latest value of sourceDirectories is even if the value is mutated after the TemplateEngine is constructed

    A forwarder so we can refer to whatever the current latest value of sourceDirectories is even if the value is mutated after the TemplateEngine is constructed

    Attributes
    protected
  99. def sourceDirectory: File

  100. def sourceFileName(uri: String): File

    Returns the source file of the template URI

    Returns the source file of the template URI

    Attributes
    protected
  101. val sourceMapLog: Log

    Attributes
    protected
  102. def storeSourceMap(classFile: File, sourceMap: String): Unit

    Attributes
    protected
  103. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  104. var templateDirectories: List[String]

    A list of directories which are searched to load requested templates.

  105. def templateExtensionsFor(extension: String): Set[String]

    Returns the mutable set of template extensions which are mapped to the given URI extension.

  106. def tmpDirectory: File

  107. def toString(): String

    Definition Classes
    TemplateEngine → AnyRef → Any
  108. def uriToSource(uri: String): UriTemplateSource

    Creates a org.fusesource.scalate.TemplateSource from a URI

    Attributes
    protected
  109. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  110. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  111. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  112. def workingDirectory: File

    If not explicitly configured this will default to using the scalate.workdir system property to specify the directory used for generating the scala source code and compiled bytecode - otherwise a temporary directory is used

  113. def workingDirectory_=(value: File): Unit

  114. def [B](y: B): (TemplateEngine, B)

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to ArrowAssoc[TemplateEngine] performed by method any2ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc

Shadowed Implicit Value Members

  1. val self: Any

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to StringAdd performed by method any2stringadd in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (templateEngine: StringAdd).self
    Definition Classes
    StringAdd
  2. val self: Any

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to StringFormat performed by method any2stringfmt in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (templateEngine: StringFormat).self
    Definition Classes
    StringFormat

Deprecated Value Members

  1. def x: TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to ArrowAssoc[TemplateEngine] performed by method any2ArrowAssoc in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (templateEngine: ArrowAssoc[TemplateEngine]).x
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use leftOfArrow instead

  2. def x: TemplateEngine

    Implicit information
    This member is added by an implicit conversion from TemplateEngine to Ensuring[TemplateEngine] performed by method any2Ensuring in scala.Predef.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (templateEngine: Ensuring[TemplateEngine]).x
    Definition Classes
    Ensuring
    Annotations
    @deprecated
    Deprecated

    (Since version 2.10.0) Use resultOfEnsuring instead

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd from TemplateEngine to StringAdd

Inherited by implicit conversion any2stringfmt from TemplateEngine to StringFormat

Inherited by implicit conversion any2ArrowAssoc from TemplateEngine to ArrowAssoc[TemplateEngine]

Inherited by implicit conversion any2Ensuring from TemplateEngine to Ensuring[TemplateEngine]

Ungrouped