Using HTML template within JS #4647
Closed
LavissaWoW
started this conversation in
General
Replies: 2 comments 1 reply
-
I think the cleaner solution would be to write a wrapper function in JS, much like e.g. clipboard(renderLink(value)); Or something to that effect |
Beta Was this translation helpful? Give feedback.
1 reply
-
Solved in a similar manner |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Working on #4606, I feel it's wise to apply the HTML in clip.html to implement a copy-to-clipboard button inside tables rather than reinventing the wheel. However, it's become apparent that I can't use the {% include %} tag in a .js-file, as that alters the MIME-type with the browser subsequently refusing to load the offending file.
Without a long-standing knowledge of the Django template framework, I can't seem to identify a solution that allows me to render this HTML dynamically inside a JS function other than manually copying it in. I don't really feel that's a very elegant solution, nor is it very future oriented.
Basically, doing this:
return `${renderLink(somedata)}{% include clip.html %}`
turns the .js file into MIME type text/html.
Am I doomed to write out the HTML in a separate function, or is there a way I can utilise clip.html from js?
Beta Was this translation helpful? Give feedback.
All reactions