mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Extend the view widget to work with subtiddlers
This commit is contained in:
parent
9a067b8dac
commit
1b620387dd
@ -46,6 +46,7 @@ Compute the internal state of the widget
|
|||||||
ViewWidget.prototype.execute = function() {
|
ViewWidget.prototype.execute = function() {
|
||||||
// Get parameters from our attributes
|
// Get parameters from our attributes
|
||||||
this.viewTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
|
this.viewTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
|
||||||
|
this.viewSubtiddler = this.getAttribute("subtiddler");
|
||||||
this.viewField = this.getAttribute("field","text");
|
this.viewField = this.getAttribute("field","text");
|
||||||
this.viewIndex = this.getAttribute("index");
|
this.viewIndex = this.getAttribute("index");
|
||||||
this.viewFormat = this.getAttribute("format","text");
|
this.viewFormat = this.getAttribute("format","text");
|
||||||
@ -95,9 +96,14 @@ ViewWidget.prototype.getValue = function(options) {
|
|||||||
if(this.viewIndex) {
|
if(this.viewIndex) {
|
||||||
value = this.wiki.extractTiddlerDataItem(this.viewTitle,this.viewIndex);
|
value = this.wiki.extractTiddlerDataItem(this.viewTitle,this.viewIndex);
|
||||||
} else {
|
} else {
|
||||||
var tiddler = this.wiki.getTiddler(this.viewTitle);
|
var tiddler;
|
||||||
|
if(this.viewSubtiddler) {
|
||||||
|
tiddler = this.wiki.getSubTiddler(this.viewTitle,this.viewSubtiddler);
|
||||||
|
} else {
|
||||||
|
tiddler = this.wiki.getTiddler(this.viewTitle);
|
||||||
|
}
|
||||||
if(tiddler) {
|
if(tiddler) {
|
||||||
if(this.viewField === "text") {
|
if(this.viewField === "text" && !this.viewSubtiddler) {
|
||||||
// Calling getTiddlerText() triggers lazy loading of skinny tiddlers
|
// Calling getTiddlerText() triggers lazy loading of skinny tiddlers
|
||||||
value = this.wiki.getTiddlerText(this.viewTitle);
|
value = this.wiki.getTiddlerText(this.viewTitle);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
title: ViewWidget
|
title: ViewWidget
|
||||||
created: 201310241419
|
created: 201310241419
|
||||||
modified: 201402220837
|
modified: 20141022131222150
|
||||||
tags: Widgets
|
tags: Widgets
|
||||||
caption: view
|
caption: view
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ The content of the `<$view>` widget is displayed if the field or property is mis
|
|||||||
|index |The name of the index to view |
|
|index |The name of the index to view |
|
||||||
|format |The format for displaying the field (see below) |
|
|format |The format for displaying the field (see below) |
|
||||||
|template |The optional template used with certain formats |
|
|template |The optional template used with certain formats |
|
||||||
|
|subtiddler |Optional SubTiddler title when the target tiddler is a [[plugin|Plugins]] (see below) |
|
||||||
|
|
||||||
!! Formats
|
!! Formats
|
||||||
|
|
||||||
@ -31,3 +32,14 @@ The following formats can be specified in the `format` attribute:
|
|||||||
|''relativedate'' |The field is interpreted as a UTC date and displayed as the interval from the present instant |
|
|''relativedate'' |The field is interpreted as a UTC date and displayed as the interval from the present instant |
|
||||||
|''stripcomments'' |The field is interpreted as JavaScript source code and any lines beginning `\\#` are stripped |
|
|''stripcomments'' |The field is interpreted as JavaScript source code and any lines beginning `\\#` are stripped |
|
||||||
|''jsencoded'' |The field is displayed as a JavaScript encoded string |
|
|''jsencoded'' |The field is displayed as a JavaScript encoded string |
|
||||||
|
|
||||||
|
! SubTiddler Access
|
||||||
|
|
||||||
|
The view widget allows access to the individual tiddlers stored within a [[plugin|Plugins]].
|
||||||
|
|
||||||
|
The following example will view the core version of the tiddler [[$:/DefaultTiddlers]] even if it has been overridden:
|
||||||
|
|
||||||
|
<<wikitext-example-without-html '
|
||||||
|
<$view tiddler="$:/core" subtiddler="$:/DefaultTiddlers"/>
|
||||||
|
|
||||||
|
'>>
|
||||||
|
Loading…
Reference in New Issue
Block a user