wycats / handlebars-site

56 stars 66 forks source link

How to check if partials does not exist? (handlebars)? #184

Closed manking99 closed 7 years ago

manking99 commented 7 years ago

When "MY BLOCK", was not registered with Handlebars.registerPartial, how to check if it not exist and throw error?

{{#"MY BLOCK"}}' '123', {{/"MY BLOCK"}}'

nknapp commented 7 years ago

First of all, {{#"MY BLOCK"}}...{{/"MY BLOCK"}} is not a partial-call. It's a block-helper call (like in https://jsfiddle.net/9D88g/167/), or a statement that iterates over an array (see https://jsfiddle.net/9D88g/168/).

For block-partial calls (like in https://jsfiddle.net/9D88g/169/), Handlebars will always evaluate the contents of the block if the partial does not exist. If it does exist and contains a {{@partial-block}} statement, the contents will be evaluated and inserted at this statement (see https://jsfiddle.net/9D88g/170/). There is no way to distinguish between these two cases.