Skip to content

Commit

Permalink
Merge pull request #31 from cgiesche/streamdeck-homeassistant-29
Browse files Browse the repository at this point in the history
streamdeck-homeassistant-29 Replace ninja-js by nunjucks
  • Loading branch information
cgiesche committed Apr 8, 2021
2 parents 0042f40 + c1df06b commit 5100f9f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./release.zip
asset_name: StreamDeckHomeAssistant.streamDeckPlugin
asset_name: StreamDeckHomeAssistant-${{ steps.tagName.outputs.tag }}.streamDeckPlugin
asset_content_type: application/zip
32 changes: 27 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"core-js": "^3.6.5",
"jinja-js": "^0.1.8",
"nunjucks": "^3.2.3",
"vue": "^2.6.11"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/Plugin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import StreamDeck from "@/modules/common/streamdeck";
import {Entity, Homeassistant} from "@/modules/common/homeassistant";
import {IconFactory} from "@/modules/plugin/imageUtils";
import jinja from "jinja-js"
import nunjucks from "nunjucks"
export default {
name: 'Plugin',
Expand Down Expand Up @@ -173,7 +173,7 @@ export default {
setButtonSVG(svg, currentContext)
if (contextSettings.useCustomTitle) {
const customTitle = jinja.render(contextSettings.buttonTitle, {...{state}, ...stateAttributes})
const customTitle = nunjucks.renderString(contextSettings.buttonTitle, {...{state}, ...stateAttributes})
this.$SD.setTitle(currentContext, customTitle);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/plugin/imageUtils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jinja from "jinja-js"
import nunjucks from "nunjucks"

const colors = {
action: "#FFFFFF",
Expand Down Expand Up @@ -214,9 +214,9 @@ const Icon = {
},

labelledIcon: (state, attributes, templates = {}, image = "", labelTopOffset = 30) => {
const line1 = jinja.render(templates.line1 || "", {...{state}, ...attributes, ...{colors}})
const line2 = jinja.render(templates.line2 || "", {...{state}, ...attributes, ...{colors}})
const line3 = jinja.render(templates.line3 || "", {...{state}, ...attributes, ...{colors}})
const line1 = nunjucks.renderString(templates.line1 || "", {...{state}, ...attributes, ...{colors}})
const line2 = nunjucks.renderString(templates.line2 || "", {...{state}, ...attributes, ...{colors}})
const line3 = nunjucks.renderString(templates.line3 || "", {...{state}, ...attributes, ...{colors}})

return `<svg width="144" height="144" xmlns="http://www.w3.org/2000/svg">
${image}
Expand Down

0 comments on commit 5100f9f

Please sign in to comment.