Templating: Update documentation with YAML/YML extensions support content

Created on 9 Jul 2019  路  5Comments  路  Source: dotnet/templating

The comment syntax for yaml/yml files is not supported, but should be treated as identical to "Language Constructs" listed in the wiki. YAML comments start with a #, and would work identically with the preprocessor syntax.

1.0 triaged

Most helpful comment

I was having the same problem and ended up trying to setup a specialCustomOperation for */.yml files based on the runnable targets wiki article.

I couldn't get it to work by setting up the if/else/else if configuration based on that, but there's another open issue 1641 which shows a different solution;

template.json:

  "SpecialCustomOperations": {
    "**/*.yml" : {
      "Operations": [
        {
          "type": "conditional",
          "configuration": {
            "style": "line",
            "token": "#"
          }
        }
      ]
    }
  }

sample.yml

thing:
  - thing1
  - thing2
##if( condition )
  - thing3
##endif
  - thing4

It's working for me. All credit goes to @williamdenton.

All 5 comments

I was having the same problem and ended up trying to setup a specialCustomOperation for */.yml files based on the runnable targets wiki article.

I couldn't get it to work by setting up the if/else/else if configuration based on that, but there's another open issue 1641 which shows a different solution;

template.json:

  "SpecialCustomOperations": {
    "**/*.yml" : {
      "Operations": [
        {
          "type": "conditional",
          "configuration": {
            "style": "line",
            "token": "#"
          }
        }
      ]
    }
  }

sample.yml

thing:
  - thing1
  - thing2
##if( condition )
  - thing3
##endif
  - thing4

It's working for me. All credit goes to @williamdenton.

Awesome! I'll give this a shot.

It would still be nice if Yaml was supported our of the box given its overseeing increasing prevalence in the software world. Especially vis-a-vis Docker.

You can do the following for yaml:

//#if (condition)
somestuff
//#endif

Might be nice to add this to the docs, especially useful for yaml pipelines.

@grinrag , let's update the docs with the above.

Added example above to wiki page.

Was this page helpful?
0 / 5 - 0 ratings