Search in sources :

Example 1 with Compiler

use of com.squarespace.template.Compiler in project template-compiler by Squarespace.

the class TemplateC method compiler.

protected Compiler compiler() {
    FormatterTable formatterTable = new FormatterTable();
    PredicateTable predicateTable = new PredicateTable();
    // core
    formatterTable.register(new CoreFormatters());
    predicateTable.register(new CorePredicates());
    // TODO: dynamic classpath scan and registration of plugin jars.
    // squarespace
    formatterTable.register(new CommerceFormatters());
    formatterTable.register(new ContentFormatters());
    formatterTable.register(new SocialFormatters());
    formatterTable.register(new InternationalFormatters());
    predicateTable.register(new CommercePredicates());
    predicateTable.register(new ContentPredicates());
    predicateTable.register(new SlidePredicates());
    predicateTable.register(new SocialPredicates());
    predicateTable.register(new InternationalPredicates());
    return new Compiler(formatterTable, predicateTable);
}
Also used : InternationalFormatters(com.squarespace.template.plugins.platform.i18n.InternationalFormatters) Compiler(com.squarespace.template.Compiler) PredicateTable(com.squarespace.template.PredicateTable) InternationalPredicates(com.squarespace.template.plugins.platform.i18n.InternationalPredicates) CorePredicates(com.squarespace.template.plugins.CorePredicates) ContentFormatters(com.squarespace.template.plugins.platform.ContentFormatters) CommercePredicates(com.squarespace.template.plugins.platform.CommercePredicates) CommerceFormatters(com.squarespace.template.plugins.platform.CommerceFormatters) SocialPredicates(com.squarespace.template.plugins.platform.SocialPredicates) ContentPredicates(com.squarespace.template.plugins.platform.ContentPredicates) CoreFormatters(com.squarespace.template.plugins.CoreFormatters) SlidePredicates(com.squarespace.template.plugins.platform.SlidePredicates) FormatterTable(com.squarespace.template.FormatterTable) SocialFormatters(com.squarespace.template.plugins.platform.SocialFormatters)

Example 2 with Compiler

use of com.squarespace.template.Compiler in project template-compiler by Squarespace.

the class MoneyFormatterTest method executeLocale.

private String executeLocale(String template, String json, String locale) throws CodeException {
    Compiler compiler = compiler();
    Context ctx = compiler.newExecutor().json(json).template(template).locale(Locale.forLanguageTag(locale)).execute();
    return ctx.buffer().toString();
}
Also used : Context(com.squarespace.template.Context) Compiler(com.squarespace.template.Compiler)

Example 3 with Compiler

use of com.squarespace.template.Compiler in project template-compiler by Squarespace.

the class MoneyFormatterTest method executeLocale.

private String executeLocale(String template, String json, CLDR.Locale locale) throws CodeException {
    Compiler compiler = compiler();
    Context ctx = compiler.newExecutor().json(json).template(template).cldrLocale(locale).execute();
    return ctx.buffer().toString();
}
Also used : Context(com.squarespace.template.Context) Compiler(com.squarespace.template.Compiler)

Example 4 with Compiler

use of com.squarespace.template.Compiler in project template-compiler by Squarespace.

the class MoneyFormatterLegacyTest method executeLocale.

private String executeLocale(String template, String json, String locale) throws CodeException {
    Compiler compiler = compiler();
    Context ctx = compiler.newExecutor().json(json).template(template).locale(Locale.forLanguageTag(locale)).execute();
    return ctx.buffer().toString();
}
Also used : Context(com.squarespace.template.Context) Compiler(com.squarespace.template.Compiler)

Aggregations

Compiler (com.squarespace.template.Compiler)4 Context (com.squarespace.template.Context)3 FormatterTable (com.squarespace.template.FormatterTable)1 PredicateTable (com.squarespace.template.PredicateTable)1 CoreFormatters (com.squarespace.template.plugins.CoreFormatters)1 CorePredicates (com.squarespace.template.plugins.CorePredicates)1 CommerceFormatters (com.squarespace.template.plugins.platform.CommerceFormatters)1 CommercePredicates (com.squarespace.template.plugins.platform.CommercePredicates)1 ContentFormatters (com.squarespace.template.plugins.platform.ContentFormatters)1 ContentPredicates (com.squarespace.template.plugins.platform.ContentPredicates)1 SlidePredicates (com.squarespace.template.plugins.platform.SlidePredicates)1 SocialFormatters (com.squarespace.template.plugins.platform.SocialFormatters)1 SocialPredicates (com.squarespace.template.plugins.platform.SocialPredicates)1 InternationalFormatters (com.squarespace.template.plugins.platform.i18n.InternationalFormatters)1 InternationalPredicates (com.squarespace.template.plugins.platform.i18n.InternationalPredicates)1