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() {
|
||||
// Get parameters from our attributes
|
||||
this.viewTitle = this.getAttribute("tiddler",this.getVariable("currentTiddler"));
|
||||
this.viewSubtiddler = this.getAttribute("subtiddler");
|
||||
this.viewField = this.getAttribute("field","text");
|
||||
this.viewIndex = this.getAttribute("index");
|
||||
this.viewFormat = this.getAttribute("format","text");
|
||||
@ -95,9 +96,14 @@ ViewWidget.prototype.getValue = function(options) {
|
||||
if(this.viewIndex) {
|
||||
value = this.wiki.extractTiddlerDataItem(this.viewTitle,this.viewIndex);
|
||||
} 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(this.viewField === "text") {
|
||||
if(this.viewField === "text" && !this.viewSubtiddler) {
|
||||
// Calling getTiddlerText() triggers lazy loading of skinny tiddlers
|
||||
value = this.wiki.getTiddlerText(this.viewTitle);
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
title: ViewWidget
|
||||
created: 201310241419
|
||||
modified: 201402220837
|
||||
modified: 20141022131222150
|
||||
tags: Widgets
|
||||
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 |
|
||||
|format |The format for displaying the field (see below) |
|
||||
|template |The optional template used with certain formats |
|
||||
|subtiddler |Optional SubTiddler title when the target tiddler is a [[plugin|Plugins]] (see below) |
|
||||
|
||||
!! 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 |
|
||||
|''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 |
|
||||
|
||||
! 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