So, I am developing a Firefox addon that adds some HTML to the DOM on any web page.
The idea here is that I use a file with a name template.htmlas a template, which is located in a folder datainside the addon folder. Then I would like to use the contents of this file template.htmlinside the variable so that I can add it to the DOM.
myAddon / data / template.html:
<div>{{test}}</div>
myAddon / Library / main.js:
var template = ...
pageMod.PageMod({
include: "*",
contentScriptFile: [data.url("jquery-1.11.2.min.js"), data.url("main.js")],
onAttach: function(worker){
worker.port.emit("sendTemplate", template);
}
});
myAddon / data / main.js
self.port.on("sendTemplate", function(template){
}
I found the "Panel" in the SDK, but I do not want to display the HTML file as a panel.
Secondly, I tried to just send the URL of the template.html resource and then to $.get(templateURL)in myAddon/data/main.js, but this did not work because Firefox does not allow resource://-file to be $.get()'d.
, HTML , , ?