Skip to content

Include variable in HTML Graphics plugin #193

Answered by ZuperZee
dmned-ph asked this question in Q&A
Discussion options

You must be logged in to vote

This plugin doesn't replace the HTML content with the variables. You can manually do it in the onInit or onRender code, though.

The easiest thing to do is to add:

htmlNode.innerHTML = htmlGraphics.props.replaceVariables(htmlNode.innerHTML);

to the onInit section.

For a bit more control you could manually add the HTML in the onInit section:

const targetElt = htmlNode.querySelector("div > div");

targetElt.innerHTML = htmlGraphics.props.replaceVariables(`
<b>ALT No.: </b>\${AltIDNo}<br>
    <b>CUSTOMER: </b>\${Customer}<br>
    <b>LOCATION: </b>\${Location}`);

The examples above use htmlGraphics.props.replaceVariables(...), which is the same as getTemplateSrv().replace(...).
https://gapit-…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dmned-ph
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants