Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

JCR SQL 2 Query - HandlebarsException

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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