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


Java Renderer類代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:27,代碼來源:DocumentsRenderer.java

示例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;
    }
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:18,代碼來源:IndexRenderer.java

示例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");
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:17,代碼來源:IndexRendererTest.java

示例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);
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:19,代碼來源:TagsRendererTest.java

示例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");
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:17,代碼來源:TagsRendererTest.java

示例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();
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:23,代碼來源:RendererTest.java

示例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);
}
 
開發者ID:jbake-org,項目名稱:jbake,代碼行數:19,代碼來源:TagsRendererTest.java

示例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");
}
 
開發者ID:jbake-org,項目名稱:jbake,代碼行數:17,代碼來源:TagsRendererTest.java

示例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();
}
 
開發者ID:jbake-org,項目名稱:jbake,代碼行數:24,代碼來源:RendererTest.java

示例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;
	}
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:14,代碼來源:SitemapRenderer.java

示例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;
	}
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:14,代碼來源:ArchiveRenderer.java

示例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;
	}
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:14,代碼來源:FeedRenderer.java

示例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;
	}
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:13,代碼來源:TagsRenderer.java

示例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");
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:13,代碼來源:DocumentsRendererTest.java

示例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);
}
 
開發者ID:ghaseminya,項目名稱:jbake-rtl-jalaali,代碼行數:14,代碼來源:FeedRendererTest.java


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