Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com)
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi
Tinderbox Users >> Exporting from Tinderbox >> Very rudimentary export-parsing question
http://www.eastgate.com/Tinderbox/forum//YaBB.cgi?num=1412177059

Message started by J Fallows on Oct 1st, 2014, 11:24am

Title: Very rudimentary export-parsing question
Post by J Fallows on Oct 1st, 2014, 11:24am

For Mark A: I am continuing to take up your invitation of asking really basic questions, in the certainty that the answers will be helpful to me and in the hope that they may be useful to some onlookers.

Here is the kindergarten-level question I have right now.

The text of the export template "HTML item" is shown, in its entirety, below. This is directly cut-and-pasted from the template.

Code:
<h3>^title^</h3>
^source^
^text^
^children(/Templates/HTML page/HTML item)


My goal is to have the export first show the item's title, then its $Source (a user attribute of the Set type, in practice a person's name), then the text.

What I get instead from this template is shown in the screen shot of a sample item.



That is, it is treating ^source^ as a literal string to be included, rather than as a reference that in this case would bring up "Zelikow." Que pasa?

Title: Re: Very rudimentary export-parsing question
Post by Mark Bernstein on Oct 1st, 2014, 12:09pm

Rather than writing

     ^source

which Tinderbox doesn't understand, try

    ^value($Source)

Title: Re: Very rudimentary export-parsing question
Post by J Fallows on Oct 1st, 2014, 12:17pm


Quote:
Rather than writing

^source

which Tinderbox doesn't understand, try

^value($Source)


Thanks! That solves the operational question. And then, for me, raises a conceptual one:

Why does Tinderbox understand ^text^ and ^title^, rather than requiring ^value($Text)^ , but does not understand ^source^ ?

Is it that ^title^ and ^text^ are unique exceptions (because of their ubiquity) to the ^value()-based approach? Or is there some other structural rule for us to be aware of here, comparable to the rule that .contains() will work with regex for string values, but not for set values?

Thanks on both practical and conceptual fronts.

Title: Re: Very rudimentary export-parsing question
Post by Mark Bernstein on Oct 1st, 2014, 12:26pm


Quote:
Why does Tinderbox understand ^text^ and ^title^, rather than requiring ^value($Text)^  , but does not understand ^source^  ?  


Partly, this is an effort to make the most common cases simple and self-explanatory.  Everyone is going to need ^text and ^title, and some people might not need much else.

We don't support ^attribute^ for fear of collisions. For example, ^include()^ is a command that includes some other note in this note, but $include is not an absurd name for a user attribute.  On balance, it's not that much harder to write ^value($include).


Title: Re: Very rudimentary export-parsing question
Post by Mark Anderson on Oct 1st, 2014, 12:33pm

Way, back, TB was much simpler and there were fewer things for TB to figure out in terms of export code.  We now have c.250 system attributes and as many custom ones as you like.

^text^ and ^title^ are special as they don't just export the $Text and $Name data but they check it for stuff that needs turning into HTML. Also in 2014 is much more accommodating of things like accents and non-Roman alphabet characters than it was in 2001. Probably in most cases ^value($Name)^ would work as well as title. ^text^ remain special - for now anyway - as it has to do things like turn web and TB links into HTML link mark-up, handle images (I know that's no functional right now) and do things like make bulleted list mark-up for lists in your source - all so you don't have to know or understand how that's done.

I'll also bang the drum for closing export codes with a ^. I know it's not a requirement but I can see no sensible reason why a learner of export code would want to increase the chance of TB getting confused as to where the codes stops> so is ^text^title implying ^text then ^title or ^text^ followed by the text 'title. Using ^text^^title^ is unambiguous. Apart from when I forget (!), I allways close my export tags.

Title: Re: Very rudimentary export-parsing question
Post by J Fallows on Oct 1st, 2014, 12:38pm

Thanks, and on this point ...

Quote:
On balance, it's not that much harder to write ^value($include).

Agree, it's not harder at all, and obvious *once it's pointed out*.

But I hadn't realized until this minute that ^title^ and ^text^ were a unique class-of-two in the export-code universe. And am I right in thinking that it is only these two?

To use my previous analogy, for me this has been like puzzling out why .contains() wasn't giving me any results with a Set attribute. (The answer being that .contains() works that way with String but not Set values.) Not griping in either case, and am glad to have these tools at hand. Just giving an illustration of potential barriers to the process of learning and becoming fluent with the tools. There are some general rules-of-the-road principles that, at least for me, have been revealed only by bothering to ask about puzzling specific cases.

This is all in the context of reminding any onlooker how valuable and robust a program I find TB6 to be.

Update And thanks to Mark A for the extra explanation of why ^title^ and especially ^text^ have unique properties, which I hadn't seen when writing what's above. As I say, it makes perfect sense now that I know it!

Title: Re: Very rudimentary export-parsing question
Post by Mark Anderson on Oct 1st, 2014, 12:56pm

It's all buried in aTbRef but I totally acknowledge there's a lot to read and you need to assimilate a lot before it swims into focus! Threads like this I think help a lot - I often have to go and look up/test things I thought I knew.

Long-term TB users will be conscious this is 'artisanal software' as opposed to something built on a corporate frame. As such, action code has grown in slightly irregular fashion and not all similar-looking codes behave the same way. Not being able to use == with a set or list is one such oddity. If not sure, rather than guess it's best to check a reference.

Tinderbox User-to-User Forum (for formal tech support please email: info@eastgate.com) » Powered by YaBB 2.2.1!
YaBB © 2000-2008. All Rights Reserved.