Search in sources :

Example 1 with Variables

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

the class DecimalFormatterTest method format.

private static String format(CLDR.Locale locale, Arguments args, String json) throws CodeException {
    Context ctx = new Context(JsonUtils.decode(json));
    ctx.cldrLocale(locale);
    DECIMAL.validateArgs(args);
    Variables variables = new Variables("@", ctx.node());
    DECIMAL.apply(ctx, args, variables);
    return variables.first().node().asText();
}
Also used : Context(com.squarespace.template.Context) Variables(com.squarespace.template.Variables)

Example 2 with Variables

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

the class MoneyFormatterTest method format.

private static String format(CLDR.Locale locale, Arguments args, String json) throws CodeException {
    Context ctx = new Context(JsonUtils.decode(json));
    ctx.cldrLocale(locale);
    MONEY.validateArgs(args);
    Variables variables = new Variables("@", ctx.node());
    MONEY.apply(ctx, args, variables);
    return variables.first().node().asText();
}
Also used : Context(com.squarespace.template.Context) Variables(com.squarespace.template.Variables)

Example 3 with Variables

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

the class LegacyMoneyFormatFactoryTest method cldr.

private String cldr(String tag, String currency, String number, boolean narrow) throws CodeException {
    Arguments args = mk.args(narrow ? " symbol:narrow" : " ");
    CLDR_MONEY.validateArgs(args);
    Locale locale = Locale.forLanguageTag(tag);
    Context ctx = new Context(moneyJson(number, currency), new StringBuilder(), locale);
    Variables variables = new Variables("@", ctx.node());
    CLDR_MONEY.apply(ctx, args, variables);
    return variables.first().node().asText();
}
Also used : Locale(java.util.Locale) Context(com.squarespace.template.Context) Variables(com.squarespace.template.Variables) Arguments(com.squarespace.template.Arguments)

Example 4 with Variables

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

the class MoneyFormatterLegacyTest method format.

private static String format(String locale, Arguments args, String json) throws CodeException {
    Context ctx = new Context(JsonUtils.decode(json));
    ctx.javaLocale(Locale.forLanguageTag(locale));
    MONEY.validateArgs(args);
    Variables variables = new Variables("@", ctx.node());
    MONEY.apply(ctx, args, variables);
    return variables.first().node().asText();
}
Also used : Context(com.squarespace.template.Context) Variables(com.squarespace.template.Variables)

Example 5 with Variables

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

the class MoneyFormatterTest method format.

private static String format(String locale, Arguments args, String json) throws CodeException {
    Context ctx = new Context(JsonUtils.decode(json));
    ctx.javaLocale(Locale.forLanguageTag(locale));
    MONEY.validateArgs(args);
    Variables variables = new Variables("@", ctx.node());
    MONEY.apply(ctx, args, variables);
    return variables.first().node().asText();
}
Also used : Context(com.squarespace.template.Context) Variables(com.squarespace.template.Variables)

Aggregations

Context (com.squarespace.template.Context)11 Variables (com.squarespace.template.Variables)11 Arguments (com.squarespace.template.Arguments)3 Locale (java.util.Locale)1