public class DefaultMustacheFactory extends Object implements MustacheFactory
Modifier and Type | Class and Description |
---|---|
protected class |
DefaultMustacheFactory.FragmentCacheLoader |
protected class |
DefaultMustacheFactory.MustacheCacheLoader |
Modifier and Type | Field and Description |
---|---|
protected com.google.common.util.concurrent.ListeningExecutorService |
les |
protected MustacheParser |
mc
This parser should work with any MustacheFactory
|
protected com.google.common.cache.LoadingCache<String,Mustache> |
mustacheCache
Create the default cache for mustache compilations.
|
protected ObjectHandler |
oh
This is the default object handler.
|
protected int |
recursionLimit |
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> |
templateCache
New templates that are generated at runtime are cached here.
|
Constructor and Description |
---|
DefaultMustacheFactory() |
DefaultMustacheFactory(File fileRoot)
Use the file system to resolve mustache templates.
|
DefaultMustacheFactory(String resourceRoot)
Use the classpath to resolve mustache templates.
|
Modifier and Type | Method and Description |
---|---|
Mustache |
compile(Reader reader,
String name)
Create a mustache given a reader and a name.
|
Mustache |
compile(Reader reader,
String file,
String sm,
String em) |
Mustache |
compile(String name)
Create a mustache given a resource name.
|
Mustache |
compilePartial(String s)
In order to handle recursion, we need a temporary thread local cache during compilation
that is ultimately thrown away after the top level partial is complete.
|
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> |
createLambdaCache() |
protected com.google.common.cache.LoadingCache<String,Mustache> |
createMustacheCache() |
MustacheVisitor |
createMustacheVisitor()
Creates the visitor for compilation.
|
void |
encode(String value,
Writer writer)
This defines how "encoded" values are encoded.
|
String |
filterText(String appended,
boolean b)
Override this method to apply any filtering to text that will appear
verbatim in the output template.
|
ExecutorService |
getExecutorService()
There is an ExecutorService that is used when executing parallel
operations when a Callable is returned from a mustache value or iterable.
|
Mustache |
getFragment(FragmentKey templateKey) |
ObjectHandler |
getObjectHandler()
The object handler knows how to transform names into fields and methods.
|
Reader |
getReader(String resourceName)
Given a resource name, construct a reader.
|
int |
getRecursionLimit() |
String |
resolvePartialPath(String dir,
String name,
String extension) |
void |
setExecutorService(ExecutorService es)
If you need to specify your own executor service you can.
|
void |
setObjectHandler(ObjectHandler oh)
You can override the default object handler post construction.
|
void |
setRecursionLimit(int recursionLimit)
Maximum recursion limit for partials.
|
String |
translate(String from)
Converts your arbitrary name to another name.
|
protected final com.google.common.cache.LoadingCache<String,Mustache> mustacheCache
protected ObjectHandler oh
protected final MustacheParser mc
protected final com.google.common.cache.LoadingCache<FragmentKey,Mustache> templateCache
protected int recursionLimit
protected com.google.common.util.concurrent.ListeningExecutorService les
public DefaultMustacheFactory()
public DefaultMustacheFactory(String resourceRoot)
resourceRoot
- public DefaultMustacheFactory(File fileRoot)
fileRoot
- public MustacheVisitor createMustacheVisitor()
MustacheFactory
createMustacheVisitor
in interface MustacheFactory
public Reader getReader(String resourceName)
MustacheFactory
getReader
in interface MustacheFactory
resourceName
- used to find the resourcepublic void encode(String value, Writer writer)
MustacheFactory
encode
in interface MustacheFactory
value
- the unencoded valuewriter
- where to encode the valuepublic ObjectHandler getObjectHandler()
MustacheFactory
getObjectHandler
in interface MustacheFactory
public void setObjectHandler(ObjectHandler oh)
oh
- public ExecutorService getExecutorService()
public void setExecutorService(ExecutorService es)
es
- public Mustache getFragment(FragmentKey templateKey)
public Mustache compile(String name)
MustacheFactory
compile
in interface MustacheFactory
name
- the name of the resourcepublic Mustache compile(Reader reader, String name)
MustacheFactory
compile
in interface MustacheFactory
reader
- the readername
- the name of the resourcepublic String translate(String from)
MustacheFactory
translate
in interface MustacheFactory
from
- the tag to replacepublic String filterText(String appended, boolean b)
appended
- b
- public void setRecursionLimit(int recursionLimit)
public int getRecursionLimit()
public Mustache compilePartial(String s)
s
- protected com.google.common.cache.LoadingCache<String,Mustache> createMustacheCache()
protected com.google.common.cache.LoadingCache<FragmentKey,Mustache> createLambdaCache()
Copyright © 2014. All rights reserved.