mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-03 09:16:55 +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++) {
|
||||
var title = tiddlers[t],
|
||||
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(tid.text);
|
||||
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
|
||||
var inputTiddlerDOM = function(node) {
|
||||
var extractTiddler = function(node) {
|
||||
var extractTextTiddler = function(node) {
|
||||
var e = node.firstChild;
|
||||
while(e && e.nodeName.toLowerCase() !== "pre") {
|
||||
e = e.nextSibling;
|
||||
@ -198,9 +198,21 @@ var inputTiddlerDOM = function(node) {
|
||||
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 = [];
|
||||
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) {
|
||||
tiddlers.push(tiddler);
|
||||
}
|
||||
|
@ -27,7 +27,9 @@
|
||||
<script id="jsBootStartArea" type="text/javascript">
|
||||
<!--@@jsbootstart@@-->
|
||||
</script>
|
||||
<div id="jsModules" style="display:none;">
|
||||
<!--@@jsmodule@@-->
|
||||
</div>
|
||||
<script id="jsBootEndArea" type="text/javascript">
|
||||
<!--@@jsbootend@@-->
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user