title: Thymeleaf 3 - multiple ternary evaluations possible?
body: <p>Does Thymeleaf 3 support multiple ternary conditions, such as:</p>
  
  <pre><code>cond1 ? do1 : cond2 ? do2 : do3
  </code></pre>
  
  <p>The following code works in Thymeleaf 3:</p>
  
  <pre><code>&lt;th:block th:replace="${toolbar == true} ? ~{common/fragments :: _$pageToolbar} :  ~{app/fragments :: ${toolbar}}"&gt;
  </code></pre>
  
  <p>Where I'm passing <code>true</code>to get the default toolbar or a <code>string</code> to get a custom toolbar.</p>
  
  <p>But this code, which should essentially remove the block if nothing is passed in the <code>toolbar</code> parameter generates a parsing exception:</p>
  
  <pre><code>&lt;th:block th:replace="${toolbar == true} ? ~{common/fragments :: _$pageToolbar} : ${toolbar != null} ? ~{app/fragments :: ${toolbar}} : ~{common/fragments :: _$empty}"&gt;
  </code></pre>
  
  <p>Maybe I'm taking the wrong approach here?</p>
  
  <p>The Thymeleaf parsing exception:</p>
  
  <pre><code>Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "${toolbar == true} ? ~{common/fragments :: _$pageToolbar} : ${toolbar != null} ? ~{app/fragments :: ${toolbar}} : ~{common/fragments :: _$empty}" (template: "common/fragments" - line 70, col 15)
  at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:62) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:44) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.computeFragment(AbstractStandardFragmentInsertionTagProcessor.java:387) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.standard.processor.AbstractStandardFragmentInsertionTagProcessor.doProcess(AbstractStandardFragmentInsertionTagProcessor.java:111) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.processor.element.AbstractAttributeTagProcessor.doProcess(AbstractAttributeTagProcessor.java:74) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.processor.element.AbstractElementTagProcessor.process(AbstractElementTagProcessor.java:95) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.util.ProcessorConfigurationUtils$ElementTagProcessorWrapper.process(ProcessorConfigurationUtils.java:633) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1314) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.engine.OpenElementTag.beHandled(OpenElementTag.java:205) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.engine.Model.process(Model.java:282) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.engine.ProcessorTemplateHandler.handleOpenElement(ProcessorTemplateHandler.java:1587) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.engine.TemplateHandlerAdapterMarkupHandler.handleOpenElementEnd(TemplateHandlerAdapterMarkupHandler.java:304) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler$InlineMarkupAdapterPreProcessorHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:278) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.standard.inline.OutputExpressionInlinePreProcessorHandler.handleOpenElementEnd(OutputExpressionInlinePreProcessorHandler.java:186) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.thymeleaf.templateparser.markup.InlinedOutputExpressionMarkupHandler.handleOpenElementEnd(InlinedOutputExpressionMarkupHandler.java:124) ~[thymeleaf-3.0.6.RELEASE.jar:3.0.6.RELEASE]
  at org.attoparser.HtmlElement.handleOpenElementEnd(HtmlElement.java:109) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  at org.attoparser.HtmlMarkupHandler.handleOpenElementEnd(HtmlMarkupHandler.java:297) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  at org.attoparser.MarkupEventProcessorHandler.handleOpenElementEnd(MarkupEventProcessorHandler.java:402) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  at org.attoparser.ParsingElementMarkupUtil.parseOpenElement(ParsingElementMarkupUtil.java:159) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  at org.attoparser.MarkupParser.parseBuffer(MarkupParser.java:710) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:301) ~[attoparser-2.0.4.RELEASE.jar:2.0.4.RELEASE]
  ... 79 common frames omitted
  </code></pre>