1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-24 22:33:16 +00:00

Add support for switching page templates

This commit is contained in:
saqimtiaz 2020-11-04 16:42:49 +01:00
parent 7134490f97
commit dbf7682d47
3 changed files with 23 additions and 7 deletions

View File

@ -22,6 +22,7 @@ exports.synchronous = true;
var PAGE_TITLE_TITLE = "$:/core/wiki/title";
var PAGE_STYLESHEET_TITLE = "$:/core/ui/PageStylesheet";
var PAGE_TEMPLATE_TITLE = "$:/core/ui/PageTemplate";
var PAGE_TEMPLATE_CONFIG_TITLE = "$:/config/ui/PageTemplate";
// Time (in ms) that we defer refreshing changes to draft tiddlers
var DRAFT_TIDDLER_TIMEOUT_TITLE = "$:/config/Drafts/TypingTimeout";
@ -52,7 +53,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_CONFIG_TITLE,{document: document, parentWidget: $tw.rootWidget, textReference: true});
$tw.pageContainer = document.createElement("div");
$tw.utils.addClass($tw.pageContainer,"tc-page-container-wrapper");
document.body.insertBefore($tw.pageContainer,document.body.firstChild);

View File

@ -1002,6 +1002,7 @@ exports.makeWidget = function(parser,options) {
Make a widget tree for transclusion
title: target tiddler title
options: as for wiki.makeWidget() plus:
options.textReference : flag to indicate whether title is a text reference
options.field: optional field to transclude (defaults to "text")
options.mode: transclusion mode "inline" or "block"
options.children: optional array of children for the transclude widget
@ -1026,12 +1027,24 @@ exports.makeTranscludeWidget = function(title,options) {
children: []},
parseTreeTransclude = {
type: "transclude",
attributes: {
tiddler: {
name: "tiddler",
type: "string",
value: title}},
isBlock: !options.parseAsInline};
attributes: {},
isBlock: !options.parseAsInline},
parseTreeTiddler;
if(options.textReference) {
parseTreeTiddler = {
name: "tiddler",
type: "indirect",
textReference: title
}
} else {
parseTreeTiddler = {
name: "tiddler",
type: "string",
value: title
}
}
parseTreeTransclude.attributes.tiddler = parseTreeTiddler;
if(options.importVariables || options.importPageMacros) {
if(options.importVariables) {
parseTreeImportVariables.attributes.filter.value = options.importVariables;

View File

@ -0,0 +1,2 @@
title: $:/config/ui/PageTemplate
text: $:/core/ui/PageTemplate