Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Choosing templates by prototype? (Read 9209 times)
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Choosing templates by prototype?
Oct 23rd, 2010, 2:34pm
 
Forgive me if this is covered elsewhere, but it is possible to dynamically select the export template based on a note's prototype? I've tried

Code:
^children(^value($Prototype+"Template")^)
 


but that doesn't seem to work, at least on a few minutes testing.

Thanks,

Rónán
Back to top
 
« Last Edit: Oct 23rd, 2010, 2:34pm by Rónán Kennedy »  
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Choosing templates by prototype?
Reply #1 - Oct 23rd, 2010, 2:40pm
 
Code:
^children(^value($Prototype+"Template")^)
  



This is going to take the name of the container's prototype, append "Template" to it, and use that for an export template.  Is that what you want to do?

Since the container "knows" what template it wants to use, why not simpy use that?

(If the container's template is "Event", the template name will be "EventPrototype" with no space; is that what you meant?")

The best way to solve these puzzles is to do them one step at a time.  First, try

    ^children(/path/to/template)

Then try

    ^children(^value($myTemplate))

where $myTemplate is "/path/to/template".  Elaborate in small steps until everything works as you want it to, instead of heading directly for the rather complex goal.
Back to top
 
 
WWW   IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #2 - Oct 23rd, 2010, 2:52pm
 
Mark

Yes, that's what I am trying to do. It does seem to work; thanks for confirming.

Rónán
Back to top
 
 
  IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #3 - Oct 23rd, 2010, 3:56pm
 
A further question, after more experimentation. The correct syntax for what I am trying to do is this:

Code:
^children(^value($Prototype(child)+"Template")) 



However, this isn't quite right. It works in most cases, but if the children have different prototypes, the export code will use the name of the template of the first note. I've tried using this, current and children instead of child, but they don't seem to work. However, I could be getting something basic wrong. Can anyone help?

Thanks,

Rónán
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Choosing templates by prototype?
Reply #4 - Oct 23rd, 2010, 4:16pm
 
I thin your code if failing because the calling [sic] code expects to use one template.  If you want the children to use their own per-notes templates, just export ^children^ with no template name, and chose the template within each note (rather than in the calling code as each item is processed). Your prototypes should set an HTML export template, which notes using the prototype then inherit.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #5 - Oct 23rd, 2010, 4:55pm
 
Mark

I see. Can I use a HTML export template setting even if I am not exporting to HTML?

Thanks,

Rónán
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Choosing templates by prototype?
Reply #6 - Oct 23rd, 2010, 6:35pm
 
The term 'HTML' is really historical and mainly serves to denote a difference from 'text' export.  As the latter is designed to export plain text, the HTML Export covers everything else: HTML, XML, text, CSS, Javascript ... whatever you want. I suspect that in 90+% of export scenarios users want to use HTML export, regardless of the actual mark-up they need to create.

Not all export codes add HTML-specific mark-up so it's possible to generate code for of scripting or mark-up methods.  What there isn't, is a built-in TeX code generator so you'll need to understand TeX tags and know where when to use them. Put another way, TB can export TeX markup code but only if you provide the necessary mark-up. This means that if you desire to maintain the basic text differences like bold or italic in a note's $Text, you'll need to turn off $HTMLMarkupText and insert the necessary TeX tags.  If you're good with command line stuff you could try and alternate, export to HTML as normal and via $HTMLExportCommand call a shell script that replaces HTML tags with the equivalent TeX ones (I don't know what TeX is so I can't say if there are exact equivalents).
Back to top
 
« Last Edit: Oct 23rd, 2010, 6:40pm by Mark Anderson »  

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #7 - Oct 24th, 2010, 2:58am
 
OK, that's what I thought. Converting HTML to LaTeX is feasible, but likely to get messy as the two are not exactly equivalent. I have also looked at exporting to MultiMarkdown and then converting to LaTeX, but it is difficult to control the LaTeX output without being comfortable hacking the XLST files, which is not a skill that I am keen to acquire.

Anyway, what you suggest, using the HTML export template attribute works well at exporting notes with a template specific to each prototype. However, this means that it is difficult to switch to exporting to (say) HTML from the same set of notes. I guess I could convert the LaTeX file to HTML, but I wonder if you can think of a way to export to both LaTeX and HTML with by-prototype template selection?

Thanks,

Rónán
Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Choosing templates by prototype?
Reply #8 - Oct 24th, 2010, 4:44am
 
If LaTeX conversion during export (via $HTMLExportCommand) isn't feasible then you want to set up your LaTeX code in the template - and if necesary inline (e.g. in the flow of $Text).

You go on to ask if it is possible to make the same TBX document export to HTML or LaTeX.  I can see a way as long as all the HTML/LaTeX markup is inserted by export templates. The method is this:
  • Make 2 versions of each export template, one HTML, one LaTeX.
  • Make a Boolean type user attribute $IsLaTeXExport.
  • Make a note displaying the above attribute as a key attribute, called "Set Export Format".
  • Make a rule in each prototype to check $IsLaTeXExport(Set Export Format) and depending on the value set their $HTMLExportTemplate to the HTML or LaTeX version.
  • Don't forget you'll need two versions of all templates, i.e. not just the templates set for the prototypes. This ensures the correct format of mark-up is written. So HTML templates must call other HTML templates and not LaTeX ones and vice versa.
If that's all too complicated, I think it will be Nature's way of suggesting you should be exporting to one format or the other and converting formats outside TB. There's likely a good open source HTML->LaTeX or LaTeX->HTML converter out there. Whilst TB is very flexible in its export methods it's primarily an analysis tool, not a text layout editor - which is the territory we're getting into above.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #9 - Oct 24th, 2010, 5:30am
 
Thanks. That was the approach I was thinking of, but it's cumbersome. There are a number of LaTeX to HTML converters out there: tex4ht seems to be the most up-to-date and actively developed, so I will use that instead.

Back to top
 
 
  IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Choosing templates by prototype?
Reply #10 - Oct 24th, 2010, 7:52am
 
Good, I'm sure that's - overall - the best approach.  It's nice to have one tool do everything but at some point it's better to start unpacking the process into a workflow of special to purpose utilities.
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Rónán Kennedy
Full Member
*
Offline



Posts: 26

Re: Choosing templates by prototype?
Reply #11 - Oct 24th, 2010, 8:17am
 
A much more Unix-y than Mac-like approach... Smiley
Back to top
 
 
  IP Logged
Pages: 1
Send Topic Print