0

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

Matt Evans
  • 31
  • 6
  • In handlebars syntax you normally seperate the arguments by using whispaces `" "` instead of comma. I think your line has to be `{{#ifCond DataSetType '==' 'TBL'}}` – RedFox Nov 05 '19 at 10:04
  • thank you that has worked!, in addition i literally also found keeping commas but using single curly braces around the data element also worked, so there appears to be 2 ways to solve it. – Matt Evans Nov 05 '19 at 10:15

1 Answers1

0

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'}}
Matt Evans
  • 31
  • 6