Search in sources :

Example 1 with GuiceSimpleScope

use of com.google.template.soy.shared.internal.GuiceSimpleScope in project closure-templates by google.

the class SoyCodeForPySubject method enterScope.

private GuiceSimpleScope.InScope enterScope() {
    GuiceSimpleScope apiCallScope1 = injector.getInstance(Key.get(GuiceSimpleScope.class, ApiCall.class));
    GuiceSimpleScope.InScope scope = apiCallScope1.enter();
    ApiCallScopeUtils.seedSharedParams(scope, null, BidiGlobalDir.LTR);
    return scope;
}
Also used : ApiCall(com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall) GuiceSimpleScope(com.google.template.soy.shared.internal.GuiceSimpleScope)

Example 2 with GuiceSimpleScope

use of com.google.template.soy.shared.internal.GuiceSimpleScope in project closure-templates by google.

the class SharedTestUtils method simulateNewApiCall.

/**
 * Simulates the start of a new Soy API call by entering/re-entering the ApiCallScope and seeding
 * scoped values common to all backends. Does not seed backend-specific API call parameters.
 *
 * @param injector The Guice injector responsible for injections during the API call.
 * @param msgBundle The bundle of translated messages, or null to use the messages from the Soy
 *     source.
 * @param bidiGlobalDir The bidi global directionality. If null, it is derived from the msgBundle
 *     locale, if any, otherwise ltr.
 * @return The ApiCallScope object (for use by the caller of this method to seed additional API
 *     call parameters, such as backend-specific parameters).
 */
public static GuiceSimpleScope.InScope simulateNewApiCall(Injector injector, @Nullable SoyMsgBundle msgBundle, @Nullable BidiGlobalDir bidiGlobalDir) {
    GuiceSimpleScope apiCallScope = injector.getInstance(Key.get(GuiceSimpleScope.class, ApiCall.class));
    GuiceSimpleScope.InScope inscope = apiCallScope.enter();
    ApiCallScopeUtils.seedSharedParams(inscope, msgBundle, bidiGlobalDir);
    return inscope;
}
Also used : ApiCall(com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall) GuiceSimpleScope(com.google.template.soy.shared.internal.GuiceSimpleScope)

Aggregations

GuiceSimpleScope (com.google.template.soy.shared.internal.GuiceSimpleScope)2 ApiCall (com.google.template.soy.shared.restricted.ApiCallScopeBindingAnnotations.ApiCall)2