当前位置: 首页>>代码示例>>Java>>正文


Java SoyModule类代码示例

本文整理汇总了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();
}
 
开发者ID:google,项目名称:closure-templates,代码行数:9,代码来源:SoySauceTest.java

示例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);
}
 
开发者ID:jleyba,项目名称:js-dossier,代码行数:9,代码来源:DossierSoyModule.java

示例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());
}
 
开发者ID:google,项目名称:closure-templates,代码行数:6,代码来源:SoyExprForPySubject.java

示例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);
}
 
开发者ID:google,项目名称:closure-templates,代码行数:80,代码来源:JspbTest.java

示例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());
}
 
开发者ID:google,项目名称:closure-templates,代码行数:15,代码来源:SoyCodeForPySubject.java


注:本文中的com.google.template.soy.SoyModule类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。