https://github.com/baristalabs/baristalabs-handlebarrit
Simple Azure Functions based Handlebars Microservice
https://github.com/baristalabs/baristalabs-handlebarrit
Last synced: 8 months ago
JSON representation
Simple Azure Functions based Handlebars Microservice
- Host: GitHub
- URL: https://github.com/baristalabs/baristalabs-handlebarrit
- Owner: BaristaLabs
- Created: 2017-09-28T22:21:28.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-07T12:29:50.000Z (about 8 years ago)
- Last Synced: 2025-01-01T14:29:34.582Z (10 months ago)
- Language: C#
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
handlebarrit
---
Azure Functions implementation that accepts a JSON request and transforms the template/data properties into a string result via Handlebars.
Ex:
POST https://handlebarrit.azurewebsites.net/api/process/
``` JSON
{
"template": "{{message}}",
"data": {
"message": "Hello, World!"
}
}
```
Response (text/html):
```
"Hello, World!"
```
It's also possible to change the response content-type via an aptly named contentType property
``` JSON
{
"template": "{{message}}",
"data": {
"message": "Hello, World!"
},
"contentType": "text/xml"
}
```
Response (text/xml):
```
Hello, World!
```
---
In addition to the Handlebars built-in helpers, the following helpers are available:
- eachBySort: Sorts the specified data by the specified property and applies the template for each.
``` JSON
[{
"template": "
{{#eachBySort tasks 'orderHint' 'desc'}}
- {{title}}
{{/eachBySort}}
",
"data": {
"tasks": [
{
"title": "something or other",
"orderHint": 12345
},
{
"title": "the first one",
"orderHint": 1000
}
]},
"contentType": "text/html"
}]
```
- currentTime: Writes the current time in the specified time zone and date/time format. Optionally: culture.
``` JSON
{
"template": "
{{currentTime 'Eastern Standard Time' 'MM-dd-yyyy h:m tt'}}
",
"data": {}
}
```
- addHours: Same as currentTime but adds the specified number of hours
``` JSON
{
"template": "
{{addHours 'Eastern Standard Time' '12' 'MM-dd-yyyy hh:mm tt'}}
",
"data": {}
}
```
- format: For the given string, attempts to parse as (1) a date time (2) a number and formats the result
``` JSON
{
"template": "
{{format startWorkTime 'h:mm tt'}}
",
"data": { "startWorkTime": "2009/03/01T10:00:00-3:00"}
}
```
- humanize - Turn an otherwise computerized string into a more readable human-friendly one.
- dehumanize - Dehumanize a human friendly string into a computer friendly one: