Using a ViewTemplate in a TestCase Widget

Is it possible to have a ViewTemplate inside the CompoundTiddler of a testcase widget be applied to other included tiddlers?

I’m trying to write some documentation, and The TestCaseWidget looks extremely useful for it. But one of the important things I’m trying to demonstrate is the use of ViewTempates, and it doesn’t seem to be applying. Here’s my setup: (ViewTemplateInTestCase.json (1.1 KB))

title: ViewTemplate in TestCase

<<testcase "docs/testcases/Customer with template">>
title: docs/testcases/Customer with template
type: text/vnd.tiddlywiki-multiple
desciption: An attempt to use a ViewTemplate in a testcase

title: Output
tags: Customer
caption: Francisco Chang
city: México D.F.
country: Mexico
first-name: Francisco
id: 13
last-name: Chang
phone: (5) 555-3392
type: text/vnd.tiddlywiki

+

title: docs/templates/Customer
tags: $:/tags/ViewTemplate
list-before: $:/core/ui/ViewTemplate/body

<% if [<currentTiddler>tag[Customer]] %>

<div class="customer-card">
<$link to=<<currentTiddler>> >{{!!caption}}</$link><br/>
<address>
  {{!!city}}, <$link to={{!!country}}/><br />
  Phone: <a href=`tel:${ [{!!phone}search-replace:g:regexp[\D],[]] }$`>{{!!phone}}</a>
</address>
</div>

<% endif %>

+

title: Narrative

Why doesn't the ~ViewTemplate work here?

Note that the ViewTemplate in the compound tiddler is not being used when displaying the Output.

Am I doing it wrong? Or is this simply not possible right now?

The tescase-widget is like a page-template. But it does not use a story-river. The only story it displays is the “Output” tiddler.

So if you add the following line as text to the Output tiddler, it will do what you want

{{||docs/templates/Customer}}

If you tag your test-tiddler with $:/tags/wiki-test-spec you do not need 2 tiddlers. The whole testcase can be done in 1 tiddler.

docs_testcases_Customer with template.json (946 Bytes)

Thank you. I did see that, and I should have mentioned it. The problem is that I want these to be a tutorial, and to do as little hand-waving as possible. If the users are going to use this technique, I really want to show them how to do it. The test cases are very close to that, but I’m missing a few things. This one is the worst.

(Another is that I’d like an optional indirection to the output tiddler, so that it doesn’t have to be named “Output” – just a field called outputTiddler or some such, that I can fill with the value customer/13. I don’t see how to do that, but I haven’t looked hard yet.)

Oh, thank you. I had that tag in there (with the two-tiddler setup) from copy-paste, and then took it out when it didn’t seem to be doing anything. But in my actual wiki, the call to <<test-case>> is only part of its tiddler. I don’t think I can do that with the single-tiddler setup.

Then the answer is “It can not be done right now”

Just brainstorming… – It should be possible to define a view-template field in the testcase tiddler, that would allow us to use view-template: $:/core/ui/ViewTemplate so the default template is used to display the “Output” tiddler.

That’s interesting

This one should be possible. But we will need to change the template that creates the testcase layout

Or might it be possible to reuse parts of what renders the tiddlers in the story river to render this as well?

I’m thinking that this might be a good way to go in general: don’t try to reuse the testcase widget for something that isn’t precisely a test-case. Instead, reuse the CompoundTiddler format, with an entirely new template for such a miniature wiki-in-a-wiki. One focused on demonstrating parts of TW, as I’m trying to do, would simply use a similar but distinct bit of code from the TestCase one.

I’ll think about it a bit, and perhaps try to create a PR in a few weeks.

Keep in mind the Inner wiki plugin is a way to include the full wiki structure such as view template display.

  • But what you are asking can still help