mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-20 00:34:50 +00:00
Added ability to load javascript modules into the tiddler store
When running in the browser
This commit is contained in:
parent
2221efdee5
commit
96d8c15f72
@ -406,7 +406,7 @@ Recipe.tiddlerOutputter = {
|
|||||||
for(var t=0; t<tiddlers.length; t++) {
|
for(var t=0; t<tiddlers.length; t++) {
|
||||||
var title = tiddlers[t],
|
var title = tiddlers[t],
|
||||||
tid = this.store.getTiddler(title);
|
tid = this.store.getTiddler(title);
|
||||||
out.push("<" + "script type=\"application/javascript\">");
|
out.push("<" + "script type=\"application/javascript\" data-tiddler-title=\"" + title + "\">");
|
||||||
out.push("define(\"" + title + "\",function(require,exports,module) {");
|
out.push("define(\"" + title + "\",function(require,exports,module) {");
|
||||||
out.push(tid.text);
|
out.push(tid.text);
|
||||||
out.push("});");
|
out.push("});");
|
||||||
|
@ -172,7 +172,7 @@ var inputTiddlyWiki = function(text,fields) {
|
|||||||
|
|
||||||
// Given a reference to a DOM node, return the tiddlers stored in the immediate child nodes
|
// Given a reference to a DOM node, return the tiddlers stored in the immediate child nodes
|
||||||
var inputTiddlerDOM = function(node) {
|
var inputTiddlerDOM = function(node) {
|
||||||
var extractTiddler = function(node) {
|
var extractTextTiddler = function(node) {
|
||||||
var e = node.firstChild;
|
var e = node.firstChild;
|
||||||
while(e && e.nodeName.toLowerCase() !== "pre") {
|
while(e && e.nodeName.toLowerCase() !== "pre") {
|
||||||
e = e.nextSibling;
|
e = e.nextSibling;
|
||||||
@ -198,9 +198,21 @@ var inputTiddlerDOM = function(node) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
extractModuleTiddler = function(node) {
|
||||||
|
if(node.hasAttribute && node.hasAttribute("data-tiddler-title")) {
|
||||||
|
return {
|
||||||
|
title: node.getAttribute("data-tiddler-title"),
|
||||||
|
text: node.innerHTML,
|
||||||
|
type: "application/javascript"
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
t,tiddlers = [];
|
t,tiddlers = [];
|
||||||
for(t = 0; t < node.childNodes.length; t++) {
|
for(t = 0; t < node.childNodes.length; t++) {
|
||||||
var tiddler = extractTiddler(node.childNodes[t]);
|
var tiddler = extractTextTiddler(node.childNodes[t]);
|
||||||
|
tiddler = tiddler || extractModuleTiddler(node.childNodes[t]);
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
tiddlers.push(tiddler);
|
tiddlers.push(tiddler);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
<script id="jsBootStartArea" type="text/javascript">
|
<script id="jsBootStartArea" type="text/javascript">
|
||||||
<!--@@jsbootstart@@-->
|
<!--@@jsbootstart@@-->
|
||||||
</script>
|
</script>
|
||||||
|
<div id="jsModules" style="display:none;">
|
||||||
<!--@@jsmodule@@-->
|
<!--@@jsmodule@@-->
|
||||||
|
</div>
|
||||||
<script id="jsBootEndArea" type="text/javascript">
|
<script id="jsBootEndArea" type="text/javascript">
|
||||||
<!--@@jsbootend@@-->
|
<!--@@jsbootend@@-->
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user