OfficeDev / acpreviewer

A Visual Studio Code Extension to Preview Adaptive Cards
Other
7 stars 3 forks source link

Support templating #7

Closed sznorbert07 closed 11 months ago

sznorbert07 commented 11 months ago

Hi, thank you so much for this extension 🎉, it really can help the development of Teams Bots.

It would be great to support Adaptive Cards templating. The cards which we use contains multiple templates for texts and for image URLs also. We are using the AdaptiveCards.Templating nuget package to populate our templates. (https://www.nuget.org/packages/AdaptiveCards.Templating)

Here is a part of the template and a screenshot of how it looks like.

...
{
  "type": "TextBlock",
  "text": "${$root.title}",
  "wrap": true,
  "fontType": "Default",
  "size": "Large",
  "weight": "Bolder",
  "spacing": "None",
  "separator": true
},
...

image

I would expect to have a text field for every field detected in the template.

dooriya commented 11 months ago

Hi @sznorbert07,

Thank you for the feedback! Actually the ACP extension has already supported Adaptive Card Templating Language.

To preview your card template with data object, you can use command Adaptive Card: New Data File to create a data file for your template JSON file. For example: https://github.com/OfficeDev/acpreviewer/blob/main/card-samples/card-elements/template.data.json is the corresponding data file of template.json, then ACP will automatically resolve the $variables when you preview the card.

sznorbert07 commented 11 months ago

Hi @dooriya,

Thank you for your quick answer. I have probably missed the information.