Handlebars.Net If Comparison helper not detecting argument type

379 Views Asked by At

Using the IfCOnd helper as defined in this post (HandleBars .Net If Comparision) I'm experiencing an issue with the helper not detecting the first argument being passed which is the particular field/attribute i want to compare the value of. My original question on the thread was deleted so i'm having to create it here as a separate question.

This is probably really simple but i've been going round in circles trying to get this working. So i'm hoping someone can help. I've implemented the condIf Helper that Hung Quach has detailed, however i can't get it to work where i want the value of a particular field in my data structure to be checked against a specified value

my handlebar syntax

{{#each ADFDatasets}}
{{#ifCond DataSetType, '==','TBL'}}
{
    "name": "{{DatsetName}}",
    "properties": {
        "linkedServiceName": {
            "referenceName": "{{LinkedServiceName}}",
            "type": "LinkedServiceReference"
        },
        "folder": {
            "name": "{{DisplayFolder}}"
        },
        "annotations": [],
        "type": "Json",
        "typeProperties": {
            "location": {
                "type": "AzureBlobFSLocation",
                "fileName": "{{FilePattern}}",
                "folderPath": "{{FolderPath}}",
                "fileSystem": "{{FileSystem}}"
             }
        }
    }
}
{{/ifCond}}
{{/each}}

the issues is with the line

{{#ifCond DataSetType, '==','TBL'}}

the data structure i'm passing it has an attribute called DataSetType (this is a string) i want to check if its value is a particular value and if so do some following logic. It just won't accept the DataSetType as the first argument an reports it as undefined.

Image of error in VS

Data Structure being passed to template

Is it simply my syntax is wrong or is this not possible? Cheers

1

There are 1 best solutions below

0
On

It turns out within the template you have to reference the data element within single curly braces.

I couldn't find any reference to this in any documentation but found it via trial and error but hopefully it will be useful for someone else

{{#ifCond {DataSetType}, '==', 'TBL'}}

also it appears RedFoxs suggestion above regarding not using commas between elements also works.

{{#ifCond DataSetType '==' 'TBL'}}