/** * @param arguments * Thymeleaf arguments * @return web context of arguments */ public static WebContext getWebContext(Arguments arguments) { return (WebContext) arguments.getContext(); } }
void processNode(final Arguments arguments, final boolean processTextNodes, final boolean processCommentNodes) { // some code if (!isPrecomputed()) { precomputeNode(arguments.getConfiguration()); } if (!isSkippable()) { // processing itself ... // move processing to children, but does not happend if node is marked as skippable doAdditionalProcess(executionArguments, executionArguments.getProcessTextNodes(), executionArguments.getProcessCommentNodes()); } }
@Override @SuppressWarnings("unchecked") protected ProcessorResult processAttribute(Arguments arguments, Element element, String attributeName) { Map<Option<?>, Object> stagingOptions = (Map<Option<?>, Object>) arguments .getLocalVariable(DataTablesDialect.INTERNAL_BEAN_COLUMN_STAGING_OPTIONS); Map<Option<?>, Extension> stagingExtensions = (Map<Option<?>, Extension>) arguments .getLocalVariable(DataTablesDialect.INTERNAL_BEAN_COLUMN_STAGING_EXTENSIONS); // Perform the actual attribute processing doProcessAttribute(arguments, element, attributeName, stagingOptions, stagingExtensions); // Housekeeping element.removeAttribute(attributeName); return ProcessorResult.ok(); }
private static Properties loadMessagesForTemplate( final Arguments arguments, final Properties defaultMessages) { Validate.notNull(arguments, "Arguments cannot be null"); Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null"); final String resourceName = arguments.getTemplateResolution().getResourceName(); final IResourceResolver resourceResolver = arguments.getTemplateResolution().getResourceResolver(); final Locale locale = arguments.getContext().getLocale(); final String templateBaseName = getTemplateFileNameBase(resourceName); return MessageResolutionUtils.loadCombinedMessagesFilesFromBaseName( arguments, resourceResolver, templateBaseName, locale, defaultMessages); }
Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null"); return MessageResolutionUtils.resolveMessageForClass( arguments.getConfiguration(), this.getClass(), arguments.getContext().getLocale(), messageKey, messageParameters);
arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName), null, PROCESSOR_NAME_FRAGMENT_FULL, true); List<Node> includefragments = fragmentandtarget.extractFragment(arguments.getConfiguration(), arguments.getContext(), arguments.getTemplateRepository());
Validate.notNull(arguments.getContext().getLocale(), "Locale in context cannot be null"); Validate.notNull(key, "Message key cannot be null"); final Locale locale = arguments.getContext().getLocale(); final String templateName = arguments.getTemplateResolution().getTemplateName(); final String cacheKey = TEMPLATE_CACHE_PREFIX + templateName + '_' + locale.toString(); ICache<String,Properties> messagesCache = null; final ICacheManager cacheManager = arguments.getConfiguration().getCacheManager(); if (cacheManager != null) { messagesCache = cacheManager.getMessageCache();
final IContext context = arguments.getContext(); if (!(context instanceof IWebContext)) { throw new ConfigurationException( final TemplateEngine templateEngine = arguments.getTemplateEngine(); this.logger.trace("[THYMELEAF][{}][{}] Executing Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\"", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue}); this.logger.trace("[THYMELEAF][{}][{}] Correctly executed Tiles Model of class {}" + "for attribute \"{}\" with value \"{}\", result is:\n{}", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), this.model.getClass().getName(), attributeName, attributeValue, templateResult});
@Override protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) { if (!arguments.hasLocalVariable(AbstractStandardSwitchStructureAttrProcessor.SWITCH_VARIABLE_NAME)) { throw new TemplateProcessingException( "Cannot specify a \"" + attributeName + "\" attribute in an environment where no " + (SwitchStructure) arguments.getLocalVariable(AbstractStandardSwitchStructureAttrProcessor.SWITCH_VARIABLE_NAME); new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.TRUE}); final Configuration configuration = arguments.getConfiguration(); final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration); new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), attributeValue, attributeName, attributeValue, Boolean.valueOf(visible)});
final IContext context = arguments.getContext(); if (!(context instanceof IWebContext)) { throw new ConfigurationException( final Attribute value = null; final TemplateEngine templateEngine = arguments.getTemplateEngine(); final StringWriter writer = new StringWriter();
precomputeNode(arguments.getConfiguration()); this.recomputeProcessorsImmediately = false; precomputeNode(arguments.getConfiguration()); arguments.addLocalVariables(this.nodeLocalVariables) : arguments); if (executionArguments.hasLocalVariables()) { unsafeSetNodeLocalVariables(executionArguments.getLocalVariables()); precomputeNode(arguments.getConfiguration()); this.recomputeProcessorsImmediately = false;
@Override protected final void checkAssertions(final Arguments arguments, final Element element, final String attributeName, final String attributeValue) { if (StringUtils.isEmptyOrWhitespace(attributeValue)) { return; } final Configuration configuration = arguments.getConfiguration(); final ExpressionSequence expressionSequence = ExpressionSequenceUtils.parseExpressionSequence(configuration, arguments, attributeValue); final List<IStandardExpression> expressions = expressionSequence.getExpressions(); for (final IStandardExpression expression : expressions) { final Object expressionResult = expression.execute(arguments.getConfiguration(), arguments); final boolean expressionBooleanResult = EvaluationUtil.evaluateAsBoolean(expressionResult); if (!expressionBooleanResult) { throw new TemplateAssertionException(expression.getStringRepresentation(), arguments.getTemplateName(), element.getLineNumber()); } } }
final Configuration configuration = arguments.getConfiguration(); if (TemplateModeUtils.isHtml(arguments.getTemplateResolution().getTemplateMode()) && ArrayUtils.contains(Standards.HTML_CONDITIONAL_FIXED_VALUE_ATTR_NAMES, newAttributeName)) {
arguments.getConfiguration(), arguments, attributeValue, dialectPrefix, fragmentSignatureAttributeName); fragment.extractFragment(arguments.getConfiguration(), arguments, arguments.getTemplateRepository());
final Configuration configuration = arguments.getConfiguration(); assignationExecutionArguments.addLocalVariables(Collections.singletonMap(newVariableName, rightValue));
@Override public ProcessorResult processTextNode(final Arguments arguments, final AbstractTextNode textNode) { if (!textNode.getProcessTextNodes()) { throw new TemplateProcessingException("Cannot execute text inlining processor: Text processors are not active"); } final Object inliner = arguments.getLocalVariable(StandardDialect.INLINER_LOCAL_VARIABLE); if (inliner == null) { if (this.logger.isTraceEnabled()) { this.logger.trace("[THYMELEAF][{}][{}] Will not process Text node as inline: no inliner has been set. " + "Please note that setting the 'processOnlyElementNodes' flag to false at a high level in the DOM " + "tree (like for example using " + ProcessAllNodesDocumentProcessor.class.getName() + ") can reduce " + "processing performance in templates with a big amount of Text nodes. Consider setting this flag " + "back to true at some point in your DOM tree to reduce this effect.", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()}); } return ProcessorResult.OK; } if (!(inliner instanceof IStandardTextInliner)) { throw new TemplateProcessingException("Cannot execute text inlining processor: Inliner set does not implement " + IStandardTextInliner.class.getName() + " (it is an object of class " + inliner.getClass().getName() + ")"); } ((IStandardTextInliner)inliner).inline(arguments, textNode); return ProcessorResult.OK; }
@Override protected final ProcessorResult doProcess(final Arguments arguments, final ProcessorMatchingContext processorMatchingContext, final Node node) { if (this.logger.isTraceEnabled()) { this.logger.trace("[THYMELEAF][{}][{}] Processing Document node of type \"{}\".", new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName(), node.getClass().getName()}); } // Because of the type of applicability being used, this cast will not fail return processDocumentNode(arguments, (Document)node); }
@Override protected List<Node> getMarkupSubstitutes(final Arguments arguments, final Element element) { final String text = getText(arguments, element); try { final TemplateRepository templateRepository = arguments.getTemplateRepository(); final List<Node> fragNodes = templateRepository.getFragment(arguments, text); for (final Node node : fragNodes) { node.setProcessable(false); } return fragNodes; } catch (final TemplateEngineException e) { throw e; } catch (final Exception e) { throw new TemplateProcessingException( "An error happened during parsing of unescaped text: \"" + element.getOriginalName() + "\"", e); } }
arguments.getConfiguration(), this.getClass(), arguments.getContext().getLocale(), messageKey, messageParameters, false); messageKey, arguments.getContext().getLocale());
arguments.getConfiguration(), arguments, element.getAttributeValue(attributeName), null, null, false); Template decorator = arguments.getTemplateRepository().getTemplate(new TemplateProcessingParameters( arguments.getConfiguration(), fragmentandtarget.getTemplateName(), arguments.getContext())); Element decoratorhtmlelement = decorator.getDocument().getFirstElementChild(); if (decoratorhtmlelement == null || !decoratorhtmlelement.getOriginalName().equals(HTML_ELEMENT_HTML)) {