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


Java Context.newContext方法代码示例

本文整理汇总了Java中com.github.jknack.handlebars.Context.newContext方法的典型用法代码示例。如果您正苦于以下问题:Java Context.newContext方法的具体用法?Java Context.newContext怎么用?Java Context.newContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.jknack.handlebars.Context的用法示例。


在下文中一共展示了Context.newContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensureReleaseBranch

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
private void ensureReleaseBranch(AdvancedSCMManager amm, String targetBranch) throws AdvancedSCMException, ReleaseBranchInvalidException{
    String releaseFileContent = null;
    if (releaseFileContentTemplate != null && !releaseFileContentTemplate.isEmpty()
            && releaseFilePath != null && !releaseFilePath.isEmpty()) {
        Handlebars handlebars = new Handlebars();
        Context templateContext = Context.newContext(null);
        templateContext.data("release", amm.getReleaseBranch(targetBranch).getReleaseName());
        Template mustacheTemplate;
        try {
            mustacheTemplate = handlebars.compileInline(releaseFileContentTemplate);
            releaseFileContent = mustacheTemplate.apply(templateContext);
        } catch (IOException e) {
            throw new AdvancedSCMException("Error rendering release file content template");
        }
    }
    amm.ensureReleaseBranch(
            targetBranch, releaseFilePath, releaseFileContent,
            "[Jenkins Integration Merge] " + targetBranch + " release", commitUsername);
}
 
开发者ID:jenkinsci,项目名称:gatekeeper-plugin,代码行数:20,代码来源:GatekeeperMerge.java

示例2: getOptions

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
Options getOptions(Object context, Map<String, Object> hash, String... params) {
    return new Options(null,
            "petrovich",
            TagType.VAR,
            Context.newContext(context),
            null,
            null,
            params,
            hash,
            null);
}
 
开发者ID:ukase,项目名称:handlebars-petrovich4j,代码行数:12,代码来源:HelperTest.java

示例3: testFragmentTemplateWithModel

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
@Test
public void testFragmentTemplateWithModel() {
    final String templateContent = "Hello {{../name}} & {{@params.name}}! Have a good day.";
    HbsFragmentRenderable fragmentRenderable = createFragmentRenderable(templateContent);
    Context parentContext = Context.newContext(ImmutableMap.of("name", "Alice"));
    Model model = new ContextModel(parentContext, ImmutableMap.of("name", "Bob"));

    String output = fragmentRenderable.render(model, createLookup(), createRequestLookup(), createAPI());
    Assert.assertEquals(output, "Hello Alice & Bob! Have a good day.");
}
 
开发者ID:wso2-attic,项目名称:carbon-uuf,代码行数:11,代码来源:HbsRenderableTest.java

示例4: testUnsupportedContext_unknownType

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
@Test
public void testUnsupportedContext_unknownType() throws Exception {

	Context ctx = Context.newContext( new Object());
	Handlebars handlebars = Mockito.mock( Handlebars.class );
	Template tpl = Mockito.mock(  Template.class  );
	Options opts = new Options(
			handlebars, "helper", TagType.SECTION, ctx, tpl, tpl,
			new Object[ 0 ],
			new HashMap<String,Object>( 0 ));

	AllHelper helper = new AllHelper();
	Assert.assertEquals( "", helper.apply( null, opts ));
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:15,代码来源:AllHelperTest.java

示例5: testUnsupportedContext_nullContext

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
@Test
public void testUnsupportedContext_nullContext() throws Exception {

	Context ctx = Context.newContext( null );
	Handlebars handlebars = Mockito.mock( Handlebars.class );
	Template tpl = Mockito.mock(  Template.class  );
	Options opts = new Options(
			handlebars, "helper", TagType.SECTION, ctx, tpl, tpl,
			new Object[ 0 ],
			new HashMap<String,Object>( 0 ));

	AllHelper helper = new AllHelper();
	Assert.assertEquals( "", helper.apply( null, opts ));
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:15,代码来源:AllHelperTest.java

示例6: buildContext

import com.github.jknack.handlebars.Context; //导入方法依赖的package包/类
private Context buildContext(final PageData pageData) {
    final Context context = Context.newContext(pageData);
    context.data("locales", singletonList(lang().language()));
    return context;
}
 
开发者ID:lauraluiz,项目名称:play-handlebars-demo,代码行数:6,代码来源:HandlebarsService.java


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