public final class DerivedTemplateUtils extends Object
A derived template is a template that is called in a specific context. A user may specify some
templates that are called in multiple contexts or a single obscure context such as the template
foo below:
{template main}
<a onclick="alert({call foo/})">{call foo /}</a>
{/template}
{template foo private="true" autoescape="contextual"}
{print $msg}
{/template}
There is no single escaping context which makes sense for $msg. So the auto-escaper
derives an extra template producing something like:
{template main}
<a onclick="alert({call foo/})">{call foo /}</a>
{/template}
{template foo private="true"}
{print $msg |escapeHtml}
{/template}
{template foo__C1234 private="true"}
{print $msg |escapeJsValue}
{/template}
Each derived template has a name that is built by name mangling an original template name with
the template's start context. A derived template's name (or qualified name) looks
like:
qualifiedName ::== baseName [separator context]
^^^^^^^^^^^^^^^^^^^
|
suffix
The base name is the name of a template in the original Soy source. The separator is a fixed
string. The context is derived from the Context.packedBits() of the template's start
context. The separator and context together form a suffix.
As shown above, the suffix is optional. The suffix is omitted for any template whose context
is the default starting context: pcdata.
| Modifier and Type | Method and Description |
|---|---|
static String |
getBaseName(String templateName)
The base name for the given template name whether derived or not.
|
static String |
getSuffix(Context startContext)
The suffix as described above.
|