@Override public Block render(Locale locale, Collection<TranslationBundle> bundles, Object... parameters) { return new CompositeBlock(); }
private Block extractResult(Block block, Map<String, Object> macroContext, boolean async) { Object resultObject = macroContext.get(MACRO_RESULT_KEY); Block result; if (resultObject instanceof List) { result = new CompositeBlock((List<Block>) resultObject); } else if (resultObject instanceof Block) { result = (Block) resultObject; } else { if (!async) { // If synchronized the top level block is a temporary macro marker so we need to get rid of it result = new CompositeBlock(block.getChildren()); } else { result = block; } // If in inline mode remove any top level paragraph. if (this.inline) { result = removeTopLevelParagraph(result); } } return result; }
@Override public Block render(Locale locale, Collection<TranslationBundle> bundles, Object... parameters) { Block block = new CompositeBlock(); for (TranslationMessageElement element : this.elements) { block.addChild(element.render(locale, bundles, parameters)); } return null; }
/** * Removes any top level paragraph since for example for the following use case we don't want an extra paragraph * block: <code>= hello {{velocity}}world{{/velocity}}</code>. * * @param blocks the blocks to check and convert */ private Block removeTopLevelParagraph(Block block) { List<Block> blocks = block.getChildren(); // Remove any top level paragraph so that the result of a macro can be used inline for example. // We only remove the paragraph if there's only one top level element and if it's a paragraph. if ((block.getChildren().size() == 1) && block.getChildren().get(0) instanceof ParagraphBlock) { Block paragraphBlock = blocks.remove(0); blocks.addAll(0, paragraphBlock.getChildren()); return new CompositeBlock(blocks); } return block; }
block = blocks.get(0); } else { block = new CompositeBlock(blocks);
@Override public Block execute() { this.progress.startStep(this, "uix.progress.execute", "Execute UIX with id [{}]", getId()); Block result; try { BlockAsyncRendererConfiguration executorConfiguration = configure(); result = this.executor.execute(executorConfiguration); } catch (Exception e) { result = new CompositeBlock(this.errorBlockGenerator .generateErrorBlocks(String.format("Failed to execute UIX with id [%s]", getId()), e, false)); } finally { this.progress.endStep(this); } return result; }