本文整理汇总了Java中com.google.template.soy.SoyModule类的典型用法代码示例。如果您正苦于以下问题:Java SoyModule类的具体用法?Java SoyModule怎么用?Java SoyModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SoyModule类属于com.google.template.soy包,在下文中一共展示了SoyModule类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import com.google.template.soy.SoyModule; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Injector injector = Guice.createInjector(new SoyModule());
SoyFileSet.Builder builder = injector.getInstance(SoyFileSet.Builder.class);
builder.add(SoySauceTest.class.getResource("strict.soy"));
builder.add(SoySauceTest.class.getResource("non_strict.soy"));
sauce = builder.build().compileTemplates();
}
示例2: configure
import com.google.template.soy.SoyModule; //导入依赖的package包/类
@Override
protected void configure() {
install(new SoyModule());
Multibinder<SoyFunction> binder = Multibinder.newSetBinder(binder(), SoyFunction.class);
binder.addBinding().to(ExternLinkFunction.class);
binder.addBinding().to(SanitizeHtmlFunction.class);
}
示例3: SoyExprForPySubject
import com.google.template.soy.SoyModule; //导入依赖的package包/类
private SoyExprForPySubject(FailureMetadata failureMetadata, String expr) {
super(failureMetadata, expr);
localVarExprs = new LocalVariableStack();
injector = Guice.createInjector(new SoyModule());
}
示例4: testHeaderParamFieldImport
import com.google.template.soy.SoyModule; //导入依赖的package包/类
/**
* Test to check that soy code that accesses proto fields, correctly generate JS that includes
* imports for the field types.
*/
@Test
public void testHeaderParamFieldImport() {
Injector injector = Guice.createInjector(new SoyModule());
SoyJsSrcOptions jsSrcOptions = new SoyJsSrcOptions();
jsSrcOptions.setShouldProvideRequireSoyNamespaces(true);
GenJsCodeVisitor genJsCodeVisitor =
JsSrcMain.createVisitor(jsSrcOptions, injector.getInstance(SoyTypeRegistry.class));
genJsCodeVisitor.jsCodeBuilder = new JsCodeBuilder();
String testFileContent =
"{namespace boo.foo}\n"
+ "\n"
+ "/** */\n"
+ "{template .goo autoescape=\"deprecated-noncontextual\"}\n"
+ " {@param moo : example.ExampleExtendable}\n"
+ " {$moo.someExtensionField}\n"
+ "{/template}\n";
ParseResult parseResult =
SoyFileSetParserBuilder.forFileContents(testFileContent)
.declaredSyntaxVersion(SyntaxVersion.V2_0)
.typeRegistry(REGISTRY)
.parse();
// Verify that the import symbol got required.
String expectedJsFileContentStart =
"// This file was automatically generated from no-path.\n"
+ "// Please don't edit this file by hand.\n"
+ "\n"
+ "/**\n"
+ " * @fileoverview Templates in namespace boo.foo.\n"
+ " * @public\n"
+ " */\n"
+ "\n"
+ "goog.provide('boo.foo');\n"
+ "\n"
+ "goog.require('proto.example.ExampleExtendable');\n"
+ "goog.require('proto.example.SomeExtension');\n"
+ "goog.require('soy.asserts');\n"
+ "\n"
+ "\n"
+ "/**\n"
+ " * @param {boo.foo.goo.Params} opt_data\n"
+ " * @param {Object<string, *>=} opt_ijData\n"
+ " * @param {Object<string, *>=} opt_ijData_deprecated\n"
+ " * @return {string}\n"
+ " * @suppress {checkTypes|uselessCode}\n"
+ " */\n"
+ "boo.foo.goo = function(opt_data, opt_ijData, opt_ijData_deprecated) {\n"
+ " opt_ijData = opt_ijData_deprecated || opt_ijData;\n"
+ " var $tmp = opt_data.moo.$jspbMessageInstance || opt_data.moo;\n"
+ " /** @type {proto.example.ExampleExtendable} */\n"
+ " var moo = soy.asserts.assertType("
+ "$tmp instanceof proto.example.ExampleExtendable, "
+ "'moo', $tmp, 'proto.example.ExampleExtendable');\n"
+ " return '' + moo.getExtension(proto.example.SomeExtension.someExtensionField);\n"
+ "};\n"
+ "/**\n"
+ " * @typedef {{\n"
+ " * moo: proto.example.ExampleExtendable,\n"
+ " * }}\n"
+ " */\n"
+ "boo.foo.goo.Params;\n"
+ "if (goog.DEBUG) {\n"
+ " boo.foo.goo.soyTemplateName = 'boo.foo.goo';\n"
+ "}\n"
+ "";
List<String> jsFilesContents =
genJsCodeVisitor.gen(
parseResult.fileSet(), parseResult.registry(), ErrorReporter.exploding());
assertThat(jsFilesContents.get(0)).isEqualTo(expectedJsFileContentStart);
}
示例5: SoyCodeForPySubject
import com.google.template.soy.SoyModule; //导入依赖的package包/类
/**
* A Subject for testing sections of Soy code. The provided data can either be an entire Soy file,
* or just the body of a template. If just a body is provided, it is wrapped with a simple
* template before compiling.
*
* @param failureStrategy The environment provided FailureStrategy.
* @param code The input Soy code to be compiled and tested.
* @param isFile Whether the provided code represents a full file.
*/
SoyCodeForPySubject(FailureMetadata failureMetadata, String code, boolean isFile) {
super(failureMetadata, code);
this.isFile = isFile;
this.injector = Guice.createInjector(new SoyModule());
}