本文整理汇总了Java中org.jbake.app.Renderer类的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Renderer类属于org.jbake.app包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
int renderedCount = 0;
final List<String> errors = new LinkedList<String>();
for (String docType : DocumentTypes.getDocumentTypes()) {
DocumentList documentList = db.getUnrenderedContent(docType);
for (Map<String, Object> page : documentList) {
try {
renderer.render(page);
renderedCount++;
} catch (Exception e) {
errors.add(e.getMessage());
}
}
}
if (!errors.isEmpty()) {
StringBuilder sb = new StringBuilder();
sb.append("Failed to render documents. Cause(s):");
for (String error : errors) {
sb.append("\n").append(error);
}
throw new RenderingException(sb.toString());
} else {
return renderedCount;
}
}
示例2: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
if (config.getBoolean(Keys.RENDER_INDEX)) {
try {
if (shouldPaginateIndex(config)) {
renderer.renderIndexPaging(config.getString(Keys.INDEX_FILE));
} else {
renderer.renderIndex(config.getString(Keys.INDEX_FILE));
}
return 1;
} catch (Exception e) {
throw new RenderingException(e);
}
} else {
return 0;
}
}
示例3: propagatesRenderingException
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test(expected = RenderingException.class)
public void propagatesRenderingException() throws Exception {
IndexRenderer renderer = new IndexRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
compositeConfiguration.setProperty(PAGINATE_INDEX, false);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
doThrow(new Exception()).when(mockRenderer).renderIndex(anyString());
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
verify(mockRenderer, never()).renderIndex("random string");
}
示例4: returnsOneWhenConfigRendersIndices
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsOneWhenConfigRendersIndices() throws Exception {
TagsRenderer renderer = new TagsRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
Set<String> tags = new HashSet(Arrays.asList("tag1", "tags2"));
when(contentStore.getTags()).thenReturn(tags);
when(mockRenderer.renderTags("random string")).thenReturn(1);
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
assertThat(renderResponse).isEqualTo(1);
}
示例5: doesRenderWhenConfigDoesNotRenderIndices
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void doesRenderWhenConfigDoesNotRenderIndices() throws Exception {
TagsRenderer renderer = new TagsRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
Set<String> tags = new HashSet(Arrays.asList("tag1", "tags2"));
when(contentStore.getTags()).thenReturn(tags);
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
verify(mockRenderer, times(1)).renderTags("random string");
}
示例6: testRenderFileWorksWhenPathHasDotInButFileDoesNot
import org.jbake.app.Renderer; //导入依赖的package包/类
/**
* See issue #300
*
* @throws Exception
*/
@Test
public void testRenderFileWorksWhenPathHasDotInButFileDoesNot() throws Exception {
final String FOLDER = "real.path";
final String FILENAME = "about";
config.setProperty(Keys.OUTPUT_EXTENSION, "");
Renderer renderer = new Renderer(db, outputPath, folder.newFolder("templates"), config, renderingEngine);
Map<String, Object> content = new HashMap<String, Object>();
content.put(Crawler.Attributes.TYPE, "page");
content.put(Crawler.Attributes.URI, "/" + FOLDER + "/" + FILENAME);
content.put(Crawler.Attributes.STATUS, "published");
renderer.render(content);
File outputFile = new File(outputPath.getAbsolutePath() + File.separatorChar + FOLDER + File.separatorChar + FILENAME);
assertThat(outputFile).isFile();
}
示例7: returnsOneWhenConfigRendersIndices
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsOneWhenConfigRendersIndices() throws Exception {
TagsRenderer renderer = new TagsRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2"));
when(contentStore.getTags()).thenReturn(tags);
when(mockRenderer.renderTags("random string")).thenReturn(1);
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
assertThat(renderResponse).isEqualTo(1);
}
示例8: doesRenderWhenConfigDoesNotRenderIndices
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void doesRenderWhenConfigDoesNotRenderIndices() throws Exception {
TagsRenderer renderer = new TagsRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(true);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
Set<String> tags = new HashSet<String>(Arrays.asList("tag1", "tags2"));
when(contentStore.getTags()).thenReturn(tags);
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
verify(mockRenderer, times(1)).renderTags("random string");
}
示例9: testRenderFileWorksWhenPathHasDotInButFileDoesNot
import org.jbake.app.Renderer; //导入依赖的package包/类
/**
* See issue #300
*
* @throws Exception
*/
@Test
public void testRenderFileWorksWhenPathHasDotInButFileDoesNot() throws Exception {
String FOLDER = "real.path";
final String FILENAME = "about";
config.setProperty(Keys.OUTPUT_EXTENSION, "");
Renderer renderer = new Renderer(db, outputPath, folder.newFolder("templates"), config, renderingEngine);
Map<String, Object> content = new HashMap<String, Object>();
content.put(Crawler.Attributes.TYPE, "page");
content.put(Crawler.Attributes.URI, "/" + FOLDER + "/" + FILENAME);
content.put(Crawler.Attributes.STATUS, "published");
renderer.render(content);
File outputFile = new File(outputPath.getAbsolutePath() + File.separatorChar + FOLDER + File.separatorChar + FILENAME);
assertThat(outputFile).isFile();
}
示例10: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
if (config.getBoolean(Keys.RENDER_SITEMAP)) {
try {
renderer.renderSitemap(config.getString(Keys.SITEMAP_FILE));
return 1;
} catch (Exception e) {
throw new RenderingException(e);
}
} else {
return 0;
}
}
示例11: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
if (config.getBoolean(Keys.RENDER_ARCHIVE)) {
try {
renderer.renderArchive(config.getString(Keys.ARCHIVE_FILE));
return 1;
} catch (Exception e) {
throw new RenderingException(e);
}
} else {
return 0;
}
}
示例12: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
if (config.getBoolean(Keys.RENDER_FEED)) {
try {
renderer.renderFeed(config.getString(Keys.FEED_FILE));
return 1;
} catch (Exception e) {
throw new RenderingException(e);
}
} else {
return 0;
}
}
示例13: render
import org.jbake.app.Renderer; //导入依赖的package包/类
@Override
public int render(Renderer renderer, ContentStore db, File destination, File templatesPath, CompositeConfiguration config) throws RenderingException {
if (config.getBoolean(Keys.RENDER_TAGS)) {
try {
return renderer.renderTags(config.getString(Keys.TAG_PATH));
} catch (Exception e) {
throw new RenderingException(e);
}
} else {
return 0;
}
}
示例14: setUp
import org.jbake.app.Renderer; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
documentsRenderer = new DocumentsRenderer();
db = mock(ContentStore.class);
renderer = mock(Renderer.class);
configuration = mock(CompositeConfiguration.class);
emptyDocumentList = new DocumentList();
destinationFile = new File("fakefile");
templatePath = new File("fakepath");
}
示例15: returnsZeroWhenConfigDoesNotRenderFeeds
import org.jbake.app.Renderer; //导入依赖的package包/类
@Test
public void returnsZeroWhenConfigDoesNotRenderFeeds() throws RenderingException {
FeedRenderer renderer = new FeedRenderer();
CompositeConfiguration compositeConfiguration = new MockCompositeConfiguration().withDefaultBoolean(false);
ContentStore contentStore = mock(ContentStore.class);
Renderer mockRenderer = mock(Renderer.class);
int renderResponse = renderer.render(mockRenderer, contentStore,
new File("fake"), new File("fake"), compositeConfiguration);
assertThat(renderResponse).isEqualTo(0);
}