JCR SQL 2 Query - HandlebarsException | Community
Skip to main content
bona-2
Level 2
February 29, 2024
Solved

JCR SQL 2 Query - HandlebarsException

  • February 29, 2024
  • 1 reply
  • 581 views

I'm attempting to construct a query to retrieve assets based on a selected JCR node type. I'm attempting to compare the nodeType variable within the following condition.

I have added condition:
{{#if '{{nodeType}}' == 'dam:Asset'}}

From the above observation, it is noted that I am encountering this exception:

Caused by: com.github.jknack.handlebars.HandlebarsException: inline@107adee3:5:21: found: '=', expected: '}}'
    {{#if '{{nodeType}}' == 'dam:Asset'}}

I tried with {{#if '{{nodeType}}' = 'dam:Asset'}}, still the same issue. 
Please let me know the appropriate syntax.

_ Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

Hi, 

The problem is your Handlebars syntax is incorrect. In Handlebars, you don't need to use {{ and }} inside an {{#if}} block, as you're already in the Handlebars context. I think below will be the correct syntax 

 

{{#if (eq type 'dam:Asset')}}

 


But please check the documentation to fix it: https://handlebarsjs.com/guide/builtin-helpers.html 

Adding an additional resource where handle this scenario: https://stackoverflow.com/questions/34252817/handlebarsjs-check-if-a-string-is-equal-to-a-value 

 

Hope this helps

1 reply

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
February 29, 2024

Hi, 

The problem is your Handlebars syntax is incorrect. In Handlebars, you don't need to use {{ and }} inside an {{#if}} block, as you're already in the Handlebars context. I think below will be the correct syntax 

 

{{#if (eq type 'dam:Asset')}}

 


But please check the documentation to fix it: https://handlebarsjs.com/guide/builtin-helpers.html 

Adding an additional resource where handle this scenario: https://stackoverflow.com/questions/34252817/handlebarsjs-check-if-a-string-is-equal-to-a-value 

 

Hope this helps

Esteban Bustamante