Skip to content

Commit

Permalink
Update templating docs (#272)
Browse files Browse the repository at this point in the history
* Update templating docs

* update the language

* Updated .Net section in sdk.md (#275)

* added custom funtion to sdk.md

* Update sdk.md

* Update sdk.md

* Update index.md

* Update language.md

* Update language.md

* Update index.md

* Update index.md

* Update toc.yml

* Update index.md

* added Troubleshooting section

* updated sdk section

* Update language.md

* Update sdk.md

* Update AdaptiveCards/templating/index.md

Co-authored-by: shalinijoshi19 <[email protected]>

* Update AdaptiveCards/templating/index.md

Co-authored-by: shalinijoshi19 <[email protected]>

* Update AdaptiveCards/templating/language.md

Co-authored-by: shalinijoshi19 <[email protected]>

* Update index.md

Co-authored-by: Joseph Woo <[email protected]>
Co-authored-by: Joseph Woo <[email protected]>
Co-authored-by: shalinijoshi19 <[email protected]>
  • Loading branch information
4 people authored May 19, 2020
1 parent 71521ff commit 170f807
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 136 deletions.
54 changes: 30 additions & 24 deletions AdaptiveCards/templating/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@
title: Templating Overview
author: matthidinger
ms.author: mahiding
ms.date: 07/29/2019
ms.date: 05/18/2020
ms.topic: article
---

# Adaptive Cards Templating (Preview)
# Adaptive Cards Templating

We're excited to share a preview of new tools that will help you **create**, **reuse**, and **share** Adaptive Cards.

> [!IMPORTANT]
>
> These features are **in preview and subject to change**. Your feedback is not only welcome, but critical to ensure we deliver the features **you** need.
> **Breaking changes** in the **May 2020 Release Candidate**
>
> The new templating release candidate package includes some minor breaking changes that you should be aware of if you've been using the older packages. Troubleshoot common migration or usage issues in the [Troubleshooting section below](Add link to the section here).
## Breaking changes as of May 2020

1. The binding syntax changed from `{...}` to `${...}`.
* For Example: `"text": "Hello {name}"` becomes `"text": "Hello ${name}"`
2. The JavaScript API no longer contains an `EvaluationContext` object. Simply pass your data to the `expand` function. Please see the [SDK page](sdk.md) for full details.
3. The .NET API was redesigned to more closely match the JavaScript API. Please see the [SDK page](sdk.md) for full details.

## How can templating help you?
## How can templating help you

Templating enables the separation of **data** from the **layout** in an Adaptive Card.

Expand Down Expand Up @@ -80,7 +89,7 @@ Paste the example below into the **Card Payload Editor** pane:
"items": [
{
"type": "Image",
"url": "{photo}",
"url": "${photo}",
"altText": "Profile picture",
"size": "Small",
"style": "Person"
Expand All @@ -93,7 +102,7 @@ Paste the example below into the **Card Payload Editor** pane:
"items": [
{
"type": "TextBlock",
"text": "Hi {name}!",
"text": "Hi ${name}!",
"size": "Medium"
},
{
Expand All @@ -107,7 +116,7 @@ Paste the example below into the **Card Payload Editor** pane:
},
{
"type": "TextBlock",
"text": "Your manager is: **{manager.name}**"
"text": "Your manager is: **${manager.name}**"
},
{
"type": "TextBlock",
Expand All @@ -117,9 +126,9 @@ Paste the example below into the **Card Payload Editor** pane:
"type": "FactSet",
"facts": [
{
"$data": "{peers}",
"title": "{name}",
"value": "{title}"
"$data": "${peers}",
"title": "${name}",
"value": "${title}"
}
]
}
Expand Down Expand Up @@ -170,12 +179,12 @@ The Templating SDKs make it possible to populate a template with real-data.

> [!NOTE]
>
> During the initial preview we only have a limited set of SDKs available. When we release there will be templating libraries for every supported Adaptive Cards platform.
> At this time templating SDKs are available for .NET and NodeJS. Over time we will release templating SDKs for all remaining Adaptive Cards platform, like iOS, Android, UWP, etc.
Platform | Install | Documentation
--- | --- | ---
JavaScript | `npm install adaptivecards-templating` | [Documentation](https://www.npmjs.com/package/adaptivecards-templating)
.NET | `nuget install AdaptiveCards.Templating` | [Documentation](https://docs.microsoft.com/adaptive-cards/templating/sdk#net)
Platform | Package | Install | Documentation
--- | --- | --- | ---
JavaScript | [![npm install](https://img.shields.io/npm/v/adaptivecards-templating.svg)](https://www.npmjs.com/package/adaptivecards-templating) | `npm install adaptivecards-templating` | [Documentation](https://www.npmjs.com/package/adaptivecards-templating)
.NET | [![Nuget install](https://img.shields.io/nuget/vpre/AdaptiveCards.Templating.svg)](https://www.nuget.org/packages/AdaptiveCards.Templating) | `dotnet add package AdaptiveCards.Templating` | [Documentation](https://docs.microsoft.com/adaptive-cards/templating/sdk#net)

### JavaScript Example

Expand All @@ -186,12 +195,11 @@ var template = new ACData.Template({
// EmployeeCardTemplate goes here
});

var dataContext = new ACData.EvaluationContext();
dataContext.$root = {
// Data goes here
};

var card = template.expand(dataContext);
var card = template.expand({
$root: {
// Your data goes here
}
});
// Now you have an AdaptiveCard ready to render!
```

Expand All @@ -213,6 +221,4 @@ All templates are flat JSON files stored in a GitHub repo so anyone can contribu
## What's next and sending feedback

Templating and the separation of presentation from data takes us a whole lot closer toward our mission: "an ecosystem for exchanging card content in a common and consistent way".

We're eager to share more as soon as we can. In the meantime please give feedback here, [GitHub](https://github.com/microsoft/AdaptiveCards), or Twitter **[@MattHidinger](https://twitter.com/matthidinger)**/**#AdaptiveCards**.
Templating and the separation of presentation from data takes us a whole lot closer toward our mission: "an ecosystem standardized content exchange between apps and services". We've got plenty to deliver in this area, so stay tuned and let us know how it's working for you on [GitHub](https://github.com/Microsoft/AdaptiveCards/issues)!
Loading

0 comments on commit 170f807

Please sign in to comment.