本文整理汇总了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);
}
示例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);
}
示例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.");
}
示例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 ));
}
示例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 ));
}
示例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;
}