mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Initial support for switching page templates (#4979)
* Add support for switching page templates
* Revert "Add support for switching page templates"
This reverts commit dbf7682d47
.
* Adopt Jeremy's approach to page template switching instead
* Fix default value of recursion marker
* Fixed issue with conditional check
This commit is contained in:
parent
2b31c7a509
commit
5aa4e4cb68
@ -21,7 +21,7 @@ exports.synchronous = true;
|
||||
// Default story and history lists
|
||||
var PAGE_TITLE_TITLE = "$:/core/wiki/title";
|
||||
var PAGE_STYLESHEET_TITLE = "$:/core/ui/PageStylesheet";
|
||||
var PAGE_TEMPLATE_TITLE = "$:/core/ui/PageTemplate";
|
||||
var PAGE_TEMPLATE_TITLE = "$:/core/ui/RootTemplate";
|
||||
|
||||
// Time (in ms) that we defer refreshing changes to draft tiddlers
|
||||
var DRAFT_TIDDLER_TIMEOUT_TITLE = "$:/config/Drafts/TypingTimeout";
|
||||
@ -52,7 +52,7 @@ exports.startup = function() {
|
||||
}));
|
||||
// Display the $:/core/ui/PageTemplate tiddler to kick off the display
|
||||
$tw.perf.report("mainRender",function() {
|
||||
$tw.pageWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TEMPLATE_TITLE,{document: document, parentWidget: $tw.rootWidget});
|
||||
$tw.pageWidgetNode = $tw.wiki.makeTranscludeWidget(PAGE_TEMPLATE_TITLE,{document: document, parentWidget: $tw.rootWidget, recursionMarker: "no"});
|
||||
$tw.pageContainer = document.createElement("div");
|
||||
$tw.utils.addClass($tw.pageContainer,"tc-page-container-wrapper");
|
||||
document.body.insertBefore($tw.pageContainer,document.body.firstChild);
|
||||
|
@ -43,6 +43,7 @@ TranscludeWidget.prototype.execute = function() {
|
||||
this.transcludeField = this.getAttribute("field");
|
||||
this.transcludeIndex = this.getAttribute("index");
|
||||
this.transcludeMode = this.getAttribute("mode");
|
||||
this.recursionMarker = this.getAttribute("recursionMarker","yes");
|
||||
// Parse the text reference
|
||||
var parseAsInline = !this.parseTreeNode.isBlock;
|
||||
if(this.transcludeMode === "inline") {
|
||||
@ -61,7 +62,9 @@ TranscludeWidget.prototype.execute = function() {
|
||||
parseTreeNodes = parser ? parser.tree : this.parseTreeNode.children;
|
||||
// Set context variables for recursion detection
|
||||
var recursionMarker = this.makeRecursionMarker();
|
||||
this.setVariable("transclusion",recursionMarker);
|
||||
if(this.recursionMarker === "yes") {
|
||||
this.setVariable("transclusion",recursionMarker);
|
||||
}
|
||||
// Check for recursion
|
||||
if(parser) {
|
||||
if(this.parentWidget && this.parentWidget.hasVariable("transclusion",recursionMarker)) {
|
||||
|
@ -1004,6 +1004,7 @@ title: target tiddler title
|
||||
options: as for wiki.makeWidget() plus:
|
||||
options.field: optional field to transclude (defaults to "text")
|
||||
options.mode: transclusion mode "inline" or "block"
|
||||
options.recursionMarker : optional flag to set a recursion marker, defaults to "yes"
|
||||
options.children: optional array of children for the transclude widget
|
||||
options.importVariables: optional importvariables filter string for macros to be included
|
||||
options.importPageMacros: optional boolean; if true, equivalent to passing "[[$:/core/ui/PageMacros]] [all[shadows+tiddlers]tag[$:/tags/Macro]!has[draft.of]]" to options.importVariables
|
||||
@ -1027,10 +1028,17 @@ exports.makeTranscludeWidget = function(title,options) {
|
||||
parseTreeTransclude = {
|
||||
type: "transclude",
|
||||
attributes: {
|
||||
recursionMarker: {
|
||||
name: "recursionMarker",
|
||||
type: "string",
|
||||
value: options.recursionMarker || "yes"
|
||||
},
|
||||
tiddler: {
|
||||
name: "tiddler",
|
||||
type: "string",
|
||||
value: title}},
|
||||
value: title
|
||||
}
|
||||
},
|
||||
isBlock: !options.parseAsInline};
|
||||
if(options.importVariables || options.importPageMacros) {
|
||||
if(options.importVariables) {
|
||||
|
3
core/ui/RootTemplate.tid
Normal file
3
core/ui/RootTemplate.tid
Normal file
@ -0,0 +1,3 @@
|
||||
title: $:/core/ui/RootTemplate
|
||||
|
||||
<$transclude tiddler={{{ [{$:/layout}has[text]] ~[[$:/core/ui/PageTemplate]] }}} mode="inline"/>
|
Loading…
Reference in New Issue
Block a user