ha-nunjucks 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<a href="https://www.buymeacoffee.com/nerwyn" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
|
|
12
12
|
|
|
13
|
-
A wrapper for nunjucks for use with Home Assistant frontend custom components to render templates. This repository offers an easy way for developers to add templating support to Home Assistant custom cards.
|
|
13
|
+
A simple wrapper for [nunjucks](https://www.npmjs.com/package/nunjucks) for use with Home Assistant frontend custom components to render [templates](https://www.home-assistant.io/docs/configuration/templating/). This repository offers an easy way for developers to add templating support to Home Assistant custom cards.
|
|
14
14
|
|
|
15
15
|
## What is nunjucks?
|
|
16
16
|
|
|
@@ -20,7 +20,13 @@ While some Home Assistant native cards support templating for certain fields, im
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Install using npm:
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
npm install ha-nunjucks
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Then import `renderTemplate` from `ha-nunjucks` and provide it with the `hass` object and a template string you want to process.
|
|
24
30
|
|
|
25
31
|
```typescript
|
|
26
32
|
import { renderTemplate } from 'ha-nunjucks';
|
|
@@ -28,7 +34,7 @@ import { renderTemplate } from 'ha-nunjucks';
|
|
|
28
34
|
const renderedString = renderTemplate(this.hass, templateString);
|
|
29
35
|
```
|
|
30
36
|
|
|
31
|
-
Rather than rendering templates on the backend,
|
|
37
|
+
Rather than rendering templates on the backend, nunjucks renders templates on the frontend. This repository uses the Home Assistant object present in all custom cards to read entity state data.
|
|
32
38
|
|
|
33
39
|
## Available Extensions
|
|
34
40
|
|
|
@@ -70,9 +76,9 @@ A shorthand for an if else statement.
|
|
|
70
76
|
|
|
71
77
|
Functions that are not from the Home Assistant templating documentation
|
|
72
78
|
|
|
73
|
-
| Name | Arguments
|
|
74
|
-
| ----------- |
|
|
75
|
-
| match_media |
|
|
79
|
+
| Name | Arguments | Description |
|
|
80
|
+
| ----------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| match_media | mediaquery | Returns the boolean result of the provided [CSS media query](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries). |
|
|
76
82
|
|
|
77
83
|
[last-commit-shield]: https://img.shields.io/github/last-commit/Nerwyn/ha-nunjucks?style=for-the-badge
|
|
78
84
|
[commits]: https://github.com/Nerwyn/service-call-tile-feature/commits/main
|