當前位置: 首頁>>代碼示例>>Java>>正文


Java MustacheFactory.compile方法代碼示例

本文整理匯總了Java中com.github.mustachejava.MustacheFactory.compile方法的典型用法代碼示例。如果您正苦於以下問題:Java MustacheFactory.compile方法的具體用法?Java MustacheFactory.compile怎麽用?Java MustacheFactory.compile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.mustachejava.MustacheFactory的用法示例。


在下文中一共展示了MustacheFactory.compile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: announce

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private String announce(NuclearStream stream, List<String> responseList, Map<String, String> context) {
    String response = responseList.get(RandomUtils.nextInt(0, responseList.size()));
    if (context == null) {
        announcePresenter.announce(stream.getPublisher().getId(), response, true, false);
    } else {
        MustacheFactory mf = new DefaultMustacheFactory();
        Mustache mustache = mf.compile(new StringReader(response), "response");
        try {
            StringWriter writer = new StringWriter();
            mustache.execute(writer, context).flush();
            response = writer.toString();
            announcePresenter.announce(stream.getPublisher().getId(), response, true, false);
        } catch (IOException e) {
            log.warn("Could not create response", e);
        }
    }
    return response;
}
 
開發者ID:quanticc,項目名稱:ugc-bot-redux,代碼行數:19,代碼來源:NuclearService.java

示例2: initialize

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
public void initialize(String mustacheTemplate)
        throws IOException
{
    InputStream stream = this.getClass().getClassLoader().getResourceAsStream(mustacheTemplate);
    if (stream == null) {
        throw new FileNotFoundException("Resource not found: " + mustacheTemplate);
    }

    // compile template
    MustacheFactory mf = new DefaultMustacheFactory();
    Reader reader = new InputStreamReader(stream, "utf-8");
    mustache = mf.compile(reader, "template");

    // output path
    if (!outputPath.exists()) {
        outputPath.mkdirs();
    }
}
 
開發者ID:UKPLab,項目名稱:argument-reasoning-comprehension-task,代碼行數:19,代碼來源:AbstractHITCreator.java

示例3: main

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
public static void main(String[] args) {
    System.out.println("Starting executor");

    if (new File("config").mkdir()) {
        System.out.println("Created config directory");
    }

    MustacheFactory mustacheFactory = new DefaultMustacheFactory();
    final Mustache filebeatMustache = mustacheFactory.compile("filebeat.yaml.mustache");
    final Mustache metricbeatMustache = mustacheFactory.compile("metricbeat.yaml.mustache");
    try {
        MesosExecutorDriver driver = new MesosExecutorDriver(new HumioExecutor(filebeatMustache, metricbeatMustache));
        final Protos.Status status = driver.run();

        System.out.println("status = " + status);
        if (status.equals(Protos.Status.DRIVER_STOPPED)) {
            System.exit(0);
        } else {
            System.err.println("Error: " + status);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:humio,項目名稱:dcos2humio,代碼行數:25,代碼來源:ExecutorApplication.java

示例4: getTemplate

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
public static String getTemplate(PXContext pxContext, PXConfiguration pxConfig, String template) throws PXException {
    try {
        // In case of challenge
        if (pxContext.getBlockAction().equals("challenge") && pxContext.getBlockActionData() != null) {
            return pxContext.getBlockActionData();
        }

        Map<String, String> props = getProps(pxContext, pxConfig);
        MustacheFactory mf = new DefaultMustacheFactory();
        Mustache m = mf.compile((getTemplate(template)), (getTemplate(template)).toString());
        StringWriter sw = new StringWriter();
        m.execute(sw, props).close();
        return sw.toString();
    } catch (IOException e) {
        throw new PXException(e);
    }

}
 
開發者ID:PerimeterX,項目名稱:perimeterx-java-sdk,代碼行數:19,代碼來源:TemplateFactory.java

示例5: buildPluginOutput

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private static void buildPluginOutput(File input) throws IOException {
    String name = parseName(input.getName());

    Dep dep = parseDep(input);
    String url = dep.toUrl(MAVEN2);
    if (testURL(url)) {
        System.out.println("URL is good: " + url);
    } else {
        throw new IOException("Invalid URL: " + url + " for dep " + dep);
    }

    HashMap<String, Object> scopes = new HashMap<String, Object>();
    scopes.put("name", name);
    scopes.put("url", url);
    scopes.put("version", (dep.version!=null)?dep.version:dep.rev);
    scopes.put("date", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
    scopes.put("md5", getUrlAsString(url + ".md5"));

    Writer writer = new OutputStreamWriter(new FileOutputStream(new File(dirOut, name+".xml")));
    MustacheFactory mf = new DefaultMustacheFactory();
    Mustache mustache = mf.compile(new StringReader(template), "template");
    mustache.execute(writer, scopes);
    writer.flush();
    writer.close();
}
 
開發者ID:OpenSageTV,項目名稱:sagetv-plugin-repo,代碼行數:26,代碼來源:BuildLibraries.java

示例6: writeFile

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private void writeFile(String headTemplateFile) {
	try {

		Reader reader = new FileReader(new File(headTemplateFile));

		log.debug(headTemplateFile);
		File outputFile = new File(headTemplateFile.split("template")[0] + "html");

		Writer writer = new FileWriter(outputFile);

		MustacheFactory mf = new DefaultMustacheFactory();
		Mustache mustache = mf.compile(reader, "example");
		mustache.execute(writer, templates);
		writer.flush();

		log.debug(Tools.readFile(outputFile.getAbsolutePath()));

	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:dessalines,項目名稱:referendum,代碼行數:22,代碼來源:WriteHTMLFiles.java

示例7: doExport

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private void doExport(MustachePojoWrapper mustachePojoWrapper) {
    MustacheFactory mf = new DefaultMustacheFactory();

    // enrich repo information
    mustachePojoWrapper.repoOwner = repoOwner;
    mustachePojoWrapper.repoName = repoName;

    try {


        for (String curTemplate : templates) {
            //TODO remove this hack!
            String reportFileName = curTemplate.replaceAll("/templates", "");

            System.out.println(">>>>>> write template " + curTemplate + " >> to >> " + reportFileName);

            Mustache curMustache = mf.compile(curTemplate);

            curMustache.execute(new PrintWriter(new File(reportFileName)), mustachePojoWrapper).flush();
            //curMustache.execute(new PrintWriter(System.out), new NonseneWrapper(issueEvents)).flush();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}
 
開發者ID:stola3,項目名稱:github-issue-events-report,代碼行數:27,代碼來源:GitHubEventsReport.java

示例8: setup

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
@Setup
public void setup() {
    MustacheFactory mustacheFactory = new DefaultMustacheFactory() {

        @Override
        public void encode(String value, Writer writer) {
            // Disable HTML escaping
            try {
                writer.write(value);
            } catch (IOException e) {
                throw new MustacheException(e);
            }
        }
    };
    template = mustacheFactory.compile("templates/stocks.mustache.html");
}
 
開發者ID:mbosecke,項目名稱:template-benchmark,代碼行數:17,代碼來源:Mustache.java

示例9: getTemplate

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
@Override
public Template getTemplate(String templateName) {
    try {
        MustacheFactory mf = new DefaultMustacheFactory();
        final Mustache mustache = mf.compile(new StringReader(Templates.loadTemplate(templateName, resourceManager)), templateName);

        return new Template() {
            @Override
            public String apply(Object data) {
                final StringWriter stringWriter = new StringWriter();
                mustache.execute(stringWriter, data);
                return stringWriter.getBuffer().toString();
            }
        };
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:undertow-io,項目名稱:undertow.js,代碼行數:19,代碼來源:MustacheTemplateProvider.java

示例10: render

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
/**
 * Get the changelog.
 *
 * @throws GitChangelogRepositoryException
 */
public void render(final Writer writer) throws GitChangelogRepositoryException {
  final MustacheFactory mf = new DefaultMustacheFactory();
  final String templateContent = checkNotNull(getTemplateContent(), "No template!");
  final StringReader reader = new StringReader(templateContent);
  final Mustache mustache = mf.compile(reader, this.settings.getTemplatePath());
  try {
    final boolean useIntegrationIfConfigured = shouldUseIntegrationIfConfigured(templateContent);
    final Changelog changelog = this.getChangelog(useIntegrationIfConfigured);
    mustache
        .execute(
            writer, //
            new Object[] {changelog, this.settings.getExtendedVariables()} //
            )
        .flush();
  } catch (final IOException e) {
    // Should be impossible!
    throw new GitChangelogRepositoryException("", e);
  }
}
 
開發者ID:tomasbjerre,項目名稱:git-changelog-lib,代碼行數:25,代碼來源:GitChangelogApi.java

示例11: compileFile

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private void compileFile(Locale locale, File file) throws IOException {
    LOGGER.debug("Parsing {} at {}", locale, file);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Before: {} ", FileUtils.readFileToString(file).trim());
    }

    final Properties p = new Properties();
    p.load(new FileReader(locales.get(locale)));

    Map<String, Object> func = new HashMap<>();
    func.put("i18n", (TemplateFunction) s -> p.getProperty(s, s));

    MustacheFactory mf = new DefaultMustacheFactory();
    Mustache mustache = mf.compile(file.getAbsolutePath());
    mustache.execute(new FileWriter(file), func).flush();

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("After: {} ", FileUtils.readFileToString(file));
    }
}
 
開發者ID:tiagobento,項目名稱:watertemplate-engine,代碼行數:22,代碼來源:Internationalization.java

示例12: conditions

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
/**
 * <pre>
 * item1=hello
 * empty(item2)
 * empty(item3)
 * empty(item4)
 * empty(item5)
 * </pre>
 * 
 * NOTE : cond3 and item3 behaviour is differ to Hogan.groovy conditions.
 * 
 * @throws Exception
 */
void conditions() throws Exception {
    Map<String, Object> boundScope = new HashMap<>();
    boundScope.put("cond1", true);
    boundScope.put("item1", "hello");
    boundScope.put("cond2", false);
    boundScope.put("item2", "bonjour");
    boundScope.put("cond3", "");
    boundScope.put("item3", "morning");
    boundScope.put("cond4", Collections.EMPTY_LIST);
    boundScope.put("item4", "afternoon");
    boundScope.put("cond5", null);
    boundScope.put("item5", "evening");

    MustacheFactory mf = new DefaultMustacheFactory();
    Mustache mustache = mf.compile("mustache-java-tmpl/conditions.mustache");
    mustache.execute(new PrintWriter(System.out), boundScope).flush();
}
 
開發者ID:msakamoto-sf,項目名稱:javasnack,代碼行數:31,代碼來源:MustacheExercise.java

示例13: getTemplatizedPodYamlString

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
public static String getTemplatizedPodYamlString(String podYaml) {
    StringWriter writer = new StringWriter();
    MustacheFactory mf = new DefaultMustacheFactory();
    Mustache mustache = mf.compile(new StringReader(podYaml), "templatePod");
    mustache.execute(writer, KubernetesInstanceFactory.getJinJavaContext());
    return writer.toString();
}
 
開發者ID:gocd,項目名稱:kubernetes-elastic-agents,代碼行數:8,代碼來源:KubernetesInstanceFactory.java

示例14: QrdaGenerator

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
private QrdaGenerator() throws IOException, TransformerConfigurationException {
	MustacheFactory mf = new DefaultMustacheFactory();
	submission = mf.compile("submission-template.xml");
	subpopulation = mf.compile("subpopulation-template.xml");
	performanceRate = mf.compile("performance-rate-template.xml");

	quality = filterQualityMeasures();
	aci = filterAciMeasures();
	ia = filterIaMeasures();
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:11,代碼來源:QrdaGenerator.java

示例15: main

import com.github.mustachejava.MustacheFactory; //導入方法依賴的package包/類
public static void main(String... args) throws IOException, TransformerConfigurationException {
	MustacheFactory mf = new DefaultMustacheFactory();
	Mustache mdTemplate = mf.compile("error-code/error-code-tempate.md");

	try (FileWriter fw = new FileWriter("./ERROR_MESSAGES.md")) {
		List<ErrorCode> errorCodes = Arrays.asList(ErrorCode.values());
		mdTemplate.execute(fw, errorCodes).flush();
		fw.flush();
	}
}
 
開發者ID:CMSgov,項目名稱:qpp-conversion-tool,代碼行數:11,代碼來源:ErrorCodeDocumentationGenerator.java


注:本文中的com.github.mustachejava.MustacheFactory.compile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。