@Provides SoyFileSet.Builder provideBuilder(SoyFileSet.CoreDependencies coreDeps) { return new SoyFileSet.Builder(coreDeps); }
@Override public SoyTofu compile(@Nullable final Collection<URL> urls) throws IOException { Preconditions.checkNotNull("compileTimeGlobalModelResolver", compileTimeGlobalModelResolver); if (urls == null || urls.isEmpty()) { throw new IOException("Unable to compile, no urls found"); } logger.debug("SoyTofu compilation of templates:" + urls.size()); final long time1 = System.currentTimeMillis(); final SoyFileSet.Builder sfsBuilder = new SoyFileSet.Builder(); for (final URL url : urls) { sfsBuilder.add(url); } addCompileTimeGlobalModel(sfsBuilder); final SoyFileSet soyFileSet = sfsBuilder.build(); final SoyTofuOptions soyTofuOptions = createSoyTofuOptions(); final SoyTofu soyTofu = soyFileSet.compileToTofu(soyTofuOptions); final long time2 = System.currentTimeMillis(); logger.debug("SoyTofu compilation complete." + (time2 - time1) + " ms"); return soyTofu; }
@Provides SoyFileSet.Builder provideBuilder(SoyFileSet.CoreDependencies coreDeps) { return new SoyFileSet.Builder(coreDeps); }
final String searchPath = config.getSearchPath(); SoyFileSet.Builder builder = new SoyFileSet.Builder();
/** * Prints the generated HTML to stdout. * @param args Not used. */ public static void main(String[] args) { // Compile the template. SoyFileSet sfs = (new SoyFileSet.Builder()).add(Resources.getResource("simple.soy")).build(); SoyTofu tofu = sfs.compileToTofu(); // Example 1. writeExampleHeader(); System.out.println(tofu.newRenderer("soy.examples.simple.helloWorld").render()); // Create a namespaced tofu object to make calls more concise. SoyTofu simpleTofu = tofu.forNamespace("soy.examples.simple"); // Example 2. writeExampleHeader(); System.out.println(simpleTofu.newRenderer(".helloName") .setData(new SoyMapData("name", "Ana")).render()); // Example 3. writeExampleHeader(); System.out.println(simpleTofu.newRenderer(".helloNames") .setData(new SoyMapData("names", new SoyListData("Bob", "Cid", "Dee"))) .render()); }
public DoccoBatch(Docco docco, File basePath, File outputPath, String[] excludes, String[] includes, URL horizonatlSoyTemplate, URL verticalSoyTemplate, DoccoFileMappingManager fileMappings, String title, String indexFilename, boolean skipNoDocco) { this.docco = docco; this.basePath = basePath; this.outputPath = outputPath; this.excludes = excludes; this.includes = includes; this.fileMappings = fileMappings; this.title = title; this.indexFilename = indexFilename; this.skipNoDocco = skipNoDocco; SoyFileSet soyFileSetH = new SoyFileSet.Builder().add(horizonatlSoyTemplate).build(); this.horizontalTofu = soyFileSetH.compileToJavaObj().forNamespace("atlassian.docco"); SoyFileSet soyFileSetV = new SoyFileSet.Builder().add(verticalSoyTemplate).build(); this.verticalTofu = soyFileSetV.compileToJavaObj().forNamespace("atlassian.docco"); }
public Docco(URL horizonatlSoyTemplate, URL verticalSoyTemplate, DoccoFileMappingManager fileMappings, boolean stripJavadoc, boolean includeDefaultResources, List<File> customResources, PegDownProcessor pegDown) { this.fileMappings = fileMappings; this.stripJavadoc = stripJavadoc; this.pegDown = pegDown; this.includeDefaultResources = includeDefaultResources; this.customResources = customResources; /*!####ToFu Anyone? Here we create the soyTofu compilers for both horizontal and vertical displays so we can reuse them when making multiple calls to render the html. */ SoyFileSet soyFileSetH = new SoyFileSet.Builder().add(horizonatlSoyTemplate).build(); this.horizontalTofu = soyFileSetH.compileToJavaObj().forNamespace("atlassian.docco"); SoyFileSet soyFileSetV = new SoyFileSet.Builder().add(verticalSoyTemplate).build(); this.verticalTofu = soyFileSetV.compileToJavaObj().forNamespace("atlassian.docco"); }
private SoyFileSet buildSoyFileSetFrom(final Collection<URL> urls) { final SoyFileSet.Builder builder = new SoyFileSet.Builder(); for (final URL url : urls) { builder.setAllowExternalCalls(true); builder.add(url); } addCompileTimeGlobalModel(builder); return builder.build(); }
/** * Creates a builder with the standard set of Soy directives, functions, and types. * * <p>If you need additional directives, functions, or types, create the Builder instance and then * call {@link Builder#addSourceFunction(SoySourceFunction)}. */ public static Builder builder() { return new Builder( new CoreDependencies(new SoySimpleScope(), ImmutableMap.of(), ImmutableMap.of())); }