[pmwiki-users] About {$:var} text-variables

J. Meijer commentgg at hotmail.com
Tue Sep 5 12:05:25 CDT 2006


I have some suggestions regarding {$:var} variables:

* name them 'text-variables' or 'accessors'

* use {#$var} syntax instead

The '#' in the {#$var} associates the variable with a section (through the '#'). The variable must now be defined within a section. The default being the entire page text. 

So it is possible to name a section, with {#$var} being the special case. Here name is extracted from section 'name':

  {#data$name}

Which matches 'Patrick' in this page source:

  [[#data]]
  Name: Patrick
  Version: 39
  State: Texas
  [[#dataend]]


! Clipboard alternatives

Though I prefer the (not yet published updated) clipboard.php (Cookbook:Clipboard) syntax:

  (:clip data:)
  Name: Patrick
  Version: 39
  State: Texas
  (:end data:)

This less cryptically defines a section as clip 'data' on the clipboard (in $Clips['data']['clip']). 
If one doesn't want the clip to appear in the text, write:

  (:cut data:)
  Name: Patrick
  Version: 39
  State: Texas
  (:end data:)

One could also allow a style parameter which would render the clip data as a table (in place):
  
  (:clip data style=table:)
  Name: Patrick
  Version: 39
  State: Texas
  (:end data:)

Or more simply (the more advanced):

  (:clipdata:)
  Name: Patrick
  Version: 39
  State: Texas
  (:enddata:)

Which would:
1. Name the clip 'data' as no name is otherwise supplied;
2. Use the clip handler 'data' to define how the clip must be handled. This may object that knows how to extract fields as necessary, i.e. an object defining the accessors. 
3. Associate a (default) rendering method that would apply formatting to the clip, and render it in place, for example as a nicely formatted table. 
Clipboard extensions providing accessors simply define the appropriately named functions and no additional markup is required. 

Before people run to the clipboard, note that it's still the first version placed to launch the main idea. 
Though the current unpublished version does perform the kind of accessors, I'd prefer the entire thing rewritten by Patrick, for two motives:
1. Clips need core support overall. F.e. IncludeText() needs to handle them. 
2. There is an unsolved issue with incorrect white space handling. 

Finally an entire clip could be pasted like a {$variable}: {#var}. 

Or alternatively, just drop the '$' and use {#var} throughout, here an example using template filling. 

(:clipfill data:)
Hello, my name is {#name}, I line in {#state}, I am {#state}. 
(:end data:)


Warning, it's only 8 degrees at this desk,

jm







ps As a comparison note the definition of the default pagelist template using clips:

(:clippagelist default:)
(:if ! equal {=$Group} {<$Group}:)

:[[{=$Group}/]] /:
(:if:)
: :[[{=$Group}/{=$Name}]]
(:end default:)

Which I believe to be more readily readable then the equivalent:

[@
[[#default]]
(:if ! equal {=$Group} {<$Group}:)

:[[{=$Group}/]] /:
(:if:)
: :[[{=$Group}/{=$Name}]]
[[#defaultend]]
@]


_________________________________________________________________
Express yourself with gadgets on Windows Live Spaces
http://discoverspaces.live.com?source=hmtag1&loc=us



More information about the pmwiki-users mailing list